diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6de4deefe..6ae1a26525 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -185,12 +185,13 @@ jobs: - name: Publish Artifacts uses: ./actions/run-gradle with: - gradle_command: publish closeAndReleaseStagingRepositories -PreleaseBuild=true -PpublishBuild=true -PgithubPublish=true -PcentralPublish=true + gradle_command: publish jreleaserDeploy -PreleaseBuild=true -PpublishBuild=true -PgithubPublish=true -PcentralPublish=true env: - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }} - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Post release: Update various files which reference version diff --git a/build.gradle b/build.gradle index d4dc5c72ea..b082d0999d 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,8 @@ * limitations under the License. */ -import org.yaml.snakeyaml.Yaml - import org.apache.tools.ant.taskdefs.condition.Os +import org.yaml.snakeyaml.Yaml buildscript { repositories { @@ -41,7 +40,7 @@ plugins { alias(libs.plugins.protobuf) alias(libs.plugins.versions) alias(libs.plugins.spotbugs) - alias(libs.plugins.nexus) + alias(libs.plugins.jreleaser) alias(libs.plugins.download) } @@ -60,7 +59,6 @@ allprojects { apply plugin: 'base' apply plugin: 'java-library' apply plugin: 'maven-publish' - apply plugin: 'signing' apply plugin: 'project-reports' apply plugin: 'com.github.ben-manes.versions' apply plugin: 'de.undercouch.download' @@ -165,14 +163,6 @@ allprojects { dependsOn tasks.jar, tasks.package } - signing { - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys(signingKey, signingPassword) - } - } - repositories { if (System.getenv("ARTIFACT_VERSION") != null) { version = "${System.getenv('ARTIFACT_VERSION')}" @@ -310,16 +300,47 @@ subprojects { // Configure publishing for maven central. This is done in the top-level build.gradle, and then // all of the subprojects configure the artifacts they want published by applying // ${rootDir}/gradle/publishing.gradle in the project gradle. By default, we publish a library -// from each package, but this can be configured by adjusting the publishLibrary variable -if (Boolean.parseBoolean(centralPublish)) { - nexusPublishing { - repositories { - sonatype { - // Update the URL now that the OSSRH service has been sunset: https://central.sonatype.org/news/20250326_ossrh_sunset/ - nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) +// from each package, but this can be configured by adjusting the publishLibrary variable. +// Each subproject will place its artifacts into the central staging repository, +// which will then be picked up by the release configuration +if (Boolean.parseBoolean(publishBuild) && Boolean.parseBoolean(centralPublish)) { + var stagingRepo = layout.buildDirectory.dir('staging-repo') + + jreleaser { + project { + authors = ['FoundationDB'] + license = 'The Apache License, Version 2.0' + licenseUrl = 'https://www.apache.org/licenses/LICENSE-2.0' + links { + homepage = 'https://foundationdb.github.io/fdb-record-layer/' + } + inceptionYear = '2015' + } + + signing { + active = 'ALWAYS' + armored = true + } + + deploy { + maven { + mavenCentral { + sonatype { + active = 'ALWAYS' + url = 'https://central.sonatype.com/api/v1/publisher' + applyMavenCentralRules = true + stage = 'FULL' + + stagingRepository(stagingRepo.get().asFile.path) + } + } } } + + dependsOnAssemble = true } + + tasks.jreleaserDeploy.inputs.dir(stagingRepo) } // Script for upgrading gradle. To upgrade the gradle version, set the property to the version diff --git a/fdb-record-layer-core-shaded/fdb-record-layer-core-shaded.gradle b/fdb-record-layer-core-shaded/fdb-record-layer-core-shaded.gradle index c3f46d943c..c0d3837c0a 100644 --- a/fdb-record-layer-core-shaded/fdb-record-layer-core-shaded.gradle +++ b/fdb-record-layer-core-shaded/fdb-record-layer-core-shaded.gradle @@ -120,9 +120,3 @@ publishing { } } - -if (Boolean.parseBoolean(centralPublish)) { - signing { - sign publishing.publications.shadow - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c4e6482b97..6bc4859419 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -153,7 +153,7 @@ test-compileOnly = [ "autoService", "jsr305" ] download = { id = "de.undercouch.download", version = "5.6.0" } gitversion = { id = "com.palantir.git-version", version = "3.1.0" } jmh = { id = "me.champeau.jmh", version = "0.7.2" } -nexus = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" } +jreleaser = { id = "org.jreleaser", version = "1.21.0" } protobuf = { id = "com.google.protobuf", version = "0.9.4" } serviceloader = { id = "com.github.harbby.gradle.serviceloader", version = "1.1.8" } shadow = { id = "com.gradleup.shadow", version = "8.3.5" } diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 79e4d82ef9..6bb05393a6 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -18,8 +18,6 @@ * limitations under the License. */ -apply plugin: 'signing' - // Add various details to the pom file to allow for publishing def addPublishingInfo(publication) { publication.pom { @@ -88,11 +86,6 @@ if (ext.publishLibrary) { } } } - if (Boolean.parseBoolean(centralPublish)) { - signing { - sign publishing.publications.library - } - } } ext { @@ -102,7 +95,21 @@ ext { publishing { if (Boolean.parseBoolean(publishBuild)) { + repositories { + if (Boolean.parseBoolean(centralPublish)) { + // For JReleaser to deploy artifacts, they must have been staged to the local staging repo. + // Mark that directory as an output and declare a dependency between publishing the + // project and deploying artifacts. + var stagingDir = rootProject.layout.buildDirectory.dir('staging-repo') + tasks.publish.outputs.dir(stagingDir) + rootProject.tasks.findByName('jreleaserDeploy').dependsOn(tasks.publish) + + maven { + url = stagingDir + } + } + if (Boolean.parseBoolean(githubPublish)) { maven { name = "GitHubPackages"