Publish to Sonatype Central #33
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to Sonatype Central | |
| on: | |
| push: | |
| branches: | |
| - sonatype-publish # for testing the action | |
| tags: | |
| - "*.*.*" # Match semantic version tags like 3.5.13 | |
| - "*.*.*-*" # Match pre-release tags like 3.6.0-beta1, 3.5.12-stg | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "17" | |
| distribution: "temurin" | |
| cache: gradle | |
| - name: Import GPG Key and Create Secring | |
| run: | | |
| echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -d | gpg --batch --import | |
| # Create secring.gpg for Gradle signing plugin compatibility | |
| gpg --batch --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --export-secret-keys > ~/.gnupg/secring.gpg | |
| # Extract last 8 characters for short format | |
| GPG_KEY_ID="${{ secrets.GPG_KEY_ID }}" | |
| echo "SHORT_GPG_KEY_ID=${GPG_KEY_ID: -8}" >> $GITHUB_ENV | |
| - name: Build and Publish to Sonatype Central | |
| run: ./gradlew clean assemble publishAllPublicationsToCentralPortal | |
| env: | |
| ORG_GRADLE_PROJECT_SIGNING_KEY_ID: ${{ env.SHORT_GPG_KEY_ID }} | |
| ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }} | |
| ORG_GRADLE_PROJECT_SIGNING_SECRET_KEY_RING_FILE: /home/runner/.gnupg/secring.gpg | |
| ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
| ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |