Release to Maven Central #3
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: Release to Maven Central | |
| # Publishes to Maven Central (Sonatype Central Portal) via the `central` profile | |
| # in pom.xml. Uses signing/publishing secrets; see RELEASE.md before | |
| # changing triggers, permissions or the environment. | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: release-maven-central | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| environment: maven-central # secrets live here, gated by required reviewers | |
| steps: | |
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up JDK, Maven settings, GPG | |
| uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| server-id: central | |
| # username/password/passphrase are env-var NAMES: setup-java writes them | |
| # into settings.xml and Maven resolves them from env at runtime (never on disk). | |
| # gpg-private-key is the actual key value: setup-java imports it here. | |
| server-username: MAVEN_CENTRAL_USERNAME | |
| server-password: MAVEN_CENTRAL_PASSWORD | |
| gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
| gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
| - name: Deploy (uploads and stages; Publish is a manual click in the Portal) | |
| run: mvn -B -ntp -P central deploy | |
| env: | |
| MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |