From d2af9c1ee615a410a0b49ac5892793ac12646953 Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Mon, 28 Nov 2022 11:55:24 +0100 Subject: [PATCH] build: Configure deployment to Maven Central with JReleaser --- .github/workflows/release.yml | 10 +++++----- build.gradle | 11 +++++++++++ jreleaser.yml | 24 ++++++++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 468dc07a..5b7e0bd5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,14 +55,11 @@ jobs: git commit -a -m "Releasing version $VERSION" git push origin master - - name: Deploy to Plugin Portal and Maven Central + - name: Deploy to Plugin Portal and stage artifacts env: - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} - GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} - run: ./gradlew -Prelease=true -Pfull-release=true :enforcer-api:publishToSonatype :enforcer-rules:publishToSonatype publishPlugins -S + run: ./gradlew -Pprofile=release publishPlugins publish cleanupStagedRepository -S - name: Release uses: jreleaser/release-action@v2 @@ -79,6 +76,9 @@ jobs: JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }} JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} + JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - name: JReleaser output if: always() diff --git a/build.gradle b/build.gradle index 8cdebc18..19b1187e 100644 --- a/build.gradle +++ b/build.gradle @@ -100,3 +100,14 @@ subprojects { resolutionStrategy.force "org.apache.commons:commons-lang3:$commonsLang3Version" } } + +// Delete Gradle artifacts not suitable for publication to Maven Central +tasks.register('cleanupStagedRepository') { + doLast { + def repoDir = project.layout.buildDirectory.dir('repos/local/release/org/kordamp/gradle').get() + repoDir.dir('enforcer-gradle-plugin').asFile.deleteDir() + repoDir.dir('enforcer').asFile.deleteDir() + repoDir.dir('project-enforcer').asFile.deleteDir() + repoDir.dir('org.kordamp.gradle.enforcer.gradle.plugin').asFile.deleteDir() + } +} \ No newline at end of file diff --git a/jreleaser.yml b/jreleaser.yml index 910cc260..86299d29 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -28,8 +28,9 @@ project: authors: - Andres Almiray license: Apache-2.0 - extraProperties: - inceptionYear: 2020 + inceptionYear: 2020 + java: + groupId: org.kordamp.gradle release: github: @@ -62,11 +63,26 @@ release: replacers: - search: 'deps: ' +signing: + active: ALWAYS + armored: true + +deploy: + maven: + nexus2: + maven-central: + active: RELEASE + url: https://s01.oss.sonatype.org/service/local + closeRepository: true + releaseRepository: true + stagingRepositories: + - build/repos/local/release + announce: twitter: - active: release + active: RELEASE status: 🚀 {{projectName}} {{projectVersion}} has been released! {{releaseNotesUrl}} mastodon: - active: release + active: RELEASE host: https://mastodon.social status: 🚀 {{projectName}} {{projectVersion}} has been released! {{releaseNotesUrl}}