From 9134245823d671a8b0fc56458fac0f7b41ff82c0 Mon Sep 17 00:00:00 2001 From: Oleg Golberg Date: Wed, 8 Mar 2023 12:51:45 -0500 Subject: [PATCH] Update the Sonatype publishing setup Migrate to https://github.com/gradle-nexus/publish-plugin to reduce flakiness --- .circleci/config.yml | 5 +---- buildSrc/build.gradle.kts | 2 +- .../kotlin/nexus-staging-conventions.gradle.kts | 16 ++++++++-------- .../kotlin/publishing-conventions.gradle.kts | 15 --------------- gradle/libs.versions.toml | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 19470d2..b50015b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,10 +63,7 @@ jobs: - read_cache - run: name: Publish release - command: "./gradlew publish --stacktrace" - - run: - name: Promote release - command: "./gradlew closeAndReleaseRepository --stacktrace" + command: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --stacktrace" workflows: version: 2.1 diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index eaf2add..e907121 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -9,6 +9,6 @@ repositories { dependencies { implementation(libs.kotlin.gradle) - implementation(libs.nexus.staging) + implementation(libs.nexus.publish) implementation(libs.spotless) } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/nexus-staging-conventions.gradle.kts b/buildSrc/src/main/kotlin/nexus-staging-conventions.gradle.kts index f51f08b..1bb522a 100644 --- a/buildSrc/src/main/kotlin/nexus-staging-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/nexus-staging-conventions.gradle.kts @@ -1,14 +1,14 @@ -import org.gradle.kotlin.dsl.configure - plugins { - id("io.codearte.nexus-staging") + id("io.github.gradle-nexus.publish-plugin") } if (isRelease()) { - nexusStaging { - username = Remote.username - password = Remote.password - packageGroup = "com.toasttab" - numberOfRetries = 50 + nexusPublishing { + repositories { + sonatype { + username.set(Remote.username) + password.set(Remote.password) + } + } } } diff --git a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts index 6e42972..543fc5b 100644 --- a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts @@ -61,19 +61,6 @@ publishing { } } } - - if (isRelease()) { - repositories { - maven { - name = "remote" - setUrl(Remote.url) - credentials { - username = Remote.username - password = Remote.password - } - } - } - } } @Suppress("IMPLICIT_CAST_TO_ANY") @@ -85,6 +72,4 @@ if (isRelease() && Pgp.key != null) { sign(this) } } -} else { - tasks.register("closeAndReleaseRepository") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fd5d8e4..0888f64 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ junit = "5.8.2" ksp = "1.7.21-1.0.8" autoservice-ksp = "1.0.0" -nexus = "0.30.0" +nexus = "1.3.0" # test mockk = "1.9.2" @@ -31,7 +31,7 @@ ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.re autoservice-ksp = { module = "dev.zacsweers.autoservice:auto-service-ksp", version.ref = "autoservice-ksp"} # plugins -nexus-staging = { module = "io.codearte.gradle.nexus:gradle-nexus-staging-plugin", version.ref = "nexus" } +nexus-publish = { module = "io.github.gradle-nexus:publish-plugin", version.ref = "nexus" } kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.11.0" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..e1bef7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists