From 99d9e6396cb4d5f1ec1fe44f1641eb5032c69ada Mon Sep 17 00:00:00 2001 From: Matheus Lenke Date: Sun, 12 Jan 2025 11:53:51 -0300 Subject: [PATCH] fix: publishing action --- .github/workflows/maven-publish.yml | 63 +++++++++++------------------ pom.xml | 37 ++++++++++------- 2 files changed, 46 insertions(+), 54 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index f645bce..dd67a79 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -8,43 +8,26 @@ jobs: publish: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - cache: 'maven' - - - name: Import GPG Key - run: | - echo "${{ secrets.GPG_SIGNING_KEY }}" | base64 --decode | gpg --batch --passphrase "${{ secrets.GPG_PASSWORD }}" --import - gpg --list-secret-keys --keyid-format LONG - - - name: Verify Secret Key Import - run: gpg --list-secret-keys --keyid-format LONG - - - name: Check GPG Version - run: gpg --version - - - name: Configure Maven settings.xml - run: | - cat << EOF > ~/.m2/settings.xml - - - - ossrh - ${{ secrets.MAVEN_USERNAME }} - ${{ secrets.MAVEN_PASSWORD }} - - - - EOF - - - name: Publish package - run: mvn --batch-mode deploy - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + # https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven + # https://github.com/actions/setup-java + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'temurin' + cache: maven + # https://central.sonatype.org/publish/generate-portal-token/ + server-id: central + server-username: MAVEN_CENTRAL_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Publish to Maven Central Portal + # if autoPublish is false (see pom.xml), we need to publish manually via https://central.sonatype.com/publishing/deployments + run: mvn --batch-mode deploy + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_PASSWORD }} + MAVEN_GPG_PASSPHRASE: '' \ No newline at end of file diff --git a/pom.xml b/pom.xml index 76ece13..999209c 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,8 @@ 21 21 UTF-8 + 0.6.0 + 3.2.7 @@ -122,10 +124,26 @@ + + + + org.sonatype.central + central-publishing-maven-plugin + ${plugin.publishing.version} + true + + central + + + false + + + + org.apache.maven.plugins maven-gpg-plugin - 1.5 + ${plugin.gpg.version} sign-artifacts @@ -133,19 +151,10 @@ sign - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar - + + true + +