Skip to content

Commit

Permalink
Automate the sonatype project close and release
Browse files Browse the repository at this point in the history
TravisCI automation used various shell scripts to upload to nexus, close the release, and mark is as a release.

That works but let's replace the scripts with the gradle plugin `io.github.gradle-nexus.publish-plugin`. This also required upgrading to a newer version of gradle.
  • Loading branch information
ljdelight committed Apr 17, 2023
1 parent 6567d40 commit ca2e699
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 338 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# There are gradle ways to do this based on input properties or env, but for now keep it simple
sed -i "s/-SNAPSHOT//g" gradle.properties
./gradlew build
./gradlew publish \
./gradlew publish closeAndReleaseSonatypeStagingRepository \
-Psigning.secretKeyRingFile=${GPG_KEY_LOCATION} \
-Psigning.keyId=${GPG_KEY_ID} \
-Psigning.password=${GPG_PASSPHRASE}
34 changes: 15 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java'
id 'maven'
id 'maven-publish'
id 'idea'
id 'eclipse'
Expand All @@ -13,6 +12,7 @@ plugins {

// Lombok plugin and gradle compat matrix https://stackoverflow.com/a/63736421
id "io.freefair.lombok" version "5.1.1"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}

apply from: 'dependencies.gradle'
Expand Down Expand Up @@ -125,24 +125,20 @@ publishing {
name = "localPublish"
url = layout.buildDirectory.dir('repos/localpublish')
}
if (Boolean.valueOf(project.property("publishSnapshot"))) {
maven {
name = "sonatypeSnapshots"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
credentials {
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')
}
}
}
if (isReleaseVersion) {
maven {
name = "sonatypeMaven2"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')
}
}
}

// Developers use the 'publish' task to publish artifacts locally for inspection, and it's important
// not to interfere with that task. However, when the 'nexusPublishing' configuration is present,
// the 'publish' task will trigger the Sonatype publish tasks.
//
// We set up the 'nexusPublishing' block only for release versions or CI-driven snapshot publishes.
if (isReleaseVersion || Boolean.valueOf(project.property("publishSnapshot"))) {
nexusPublishing {
repositories {
sonatype {
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=org.maproulette.client
# Be sure to keep the trailing '-SNAPSHOT' in the version so that automation works correctly.
# Publishing snapshots: New commits on main or dev will publish snapshot builds
# Publishing release: A GitHub Release (using the UI) trigger a build which removes the trailing '-SNAPSHOT'.
version=0.4.3-SNAPSHOT
version=0.4.4-SNAPSHOT

maven2_url=https://oss.sonatype.org/service/local/staging/deploy/maven2/
snapshot_url=https://oss.sonatype.org/content/repositories/snapshots/
Expand Down
14 changes: 0 additions & 14 deletions gradle/dropSonatype.sh

This file was deleted.

14 changes: 0 additions & 14 deletions gradle/releaseSonatype.sh

This file was deleted.

65 changes: 0 additions & 65 deletions gradle/uploadAndRelease.sh

This file was deleted.

12 changes: 0 additions & 12 deletions gradle/uploadToNexus.sh

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Oct 28 10:36:55 PDT 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ca2e699

Please sign in to comment.