Skip to content

Commit

Permalink
chore: update build file
Browse files Browse the repository at this point in the history
  • Loading branch information
mohnoor94 committed Sep 12, 2024
1 parent 653b43f commit 531a84e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
echo "Release SDK to Maven Central"
echo "Releasing..."
cd code
gradle clean build publish -Psigning.gnupg.passphrase=$GPG_PASSPHRASE --no-daemon
26 changes: 19 additions & 7 deletions code/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ java {
targetCompatibility = JavaVersion.VERSION_11
}

def mavenRepository(name, url) {
return {
maven {
name = name
url = uri(url)
credentials {
username = System.getenv("SONATYPE_USERNAME") ?: findProperty('ARTIFACTORY_USER')
password = System.getenv("SONATYPE_PASSWORD") ?: findProperty('ARTIFACTORY_PASS')
}
}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -87,13 +100,12 @@ publishing {
}

repositories {
maven {
name = "oss-sonatype-snapshots"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
credentials {
username = System.getenv("SONATYPE_USERNAME") ?: findProperty('ARTIFACTORY_USER')
password = System.getenv("SONATYPE_PASSWORD") ?: findProperty('ARTIFACTORY_PASS')
}
if (project.version.contains("SNAPSHOT")) {
println("Publishing to Sonatype Snapshots: $project.version")
mavenRepository("oss-sonatype-snapshots", "https://oss.sonatype.org/content/repositories/snapshots")()
} else {
println("Publishing to Sonatype Releases: $project.version")
mavenRepository("oss-sonatype-releases", "https://oss.sonatype.org/service/local/staging/deploy/maven2/")()
}
}
}
Expand Down

0 comments on commit 531a84e

Please sign in to comment.