From d032c02336fc8757bd9b6d812a0e9756dd0419c7 Mon Sep 17 00:00:00 2001 From: yangbo <0049003951@znv.com> Date: Tue, 3 Sep 2024 15:42:51 +0800 Subject: [PATCH] using jreleaser to publish --- .github/workflows/publish.yml | 18 ++++++++------ build.gradle | 31 +++++++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3afcfc2..2e24e57 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,18 +10,22 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'adopt' - java-version: '8' + java-version: '17' - name: prepare - run: | - chmod a+x ./gradlew - echo "${{ secrets.SIGNING_SECRET_KEY_RING_KEY }}" | base64 -d > ~/secring.gpg + run: chmod a+x ./gradlew - name: build run: ./gradlew :build env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - name: publish - run: ./gradlew :publish -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/secring.gpg) + run: ./gradlew :publish + - name: release + run: ./gradlew :jreleaserRelease env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} \ No newline at end of file + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} + JRELEASER_GITHUB_TOKEN: 'none' + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f30df88..6d1d2b9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,9 @@ -import java.nio.charset.StandardCharsets -import java.util.stream.Collectors - plugins { id 'java-library' - id 'io.freefair.lombok' version '6.6.1' + id 'io.freefair.lombok' version '8.10' id 'maven-publish' id 'signing' + id 'org.jreleaser' version '1.14.0' } group 'io.github.ya-b' @@ -87,17 +85,26 @@ publishing { } repositories { maven { - def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - credentials { - username System.getenv("SONATYPE_USERNAME") - password System.getenv("SONATYPE_PASSWORD") - } + url = layout.buildDirectory.dir('staging-deploy') } } +} + +jreleaser { signing { - sign publishing.publications.mavenJava + active = 'ALWAYS' + armored = true + } + deploy { + maven { + mavenCentral { + sonatype { + active = 'ALWAYS' + url = 'https://central.sonatype.com/api/v1/publisher' + stagingRepository('build/staging-deploy') + } + } + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..0d18421 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.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists