Publish to the Maven Central Repository #2
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 the Maven Central Repository | |
| on: | |
| release: | |
| types: [ published ] | |
| workflow_dispatch: | |
| inputs: | |
| dryRun: | |
| description: "Dry-Run (skip deploy and push-back)" | |
| default: false | |
| required: false | |
| type: boolean | |
| logLevel: | |
| description: "Log-Level" | |
| required: false | |
| default: 'info' | |
| type: choice | |
| options: | |
| - info | |
| - warn | |
| - debug | |
| - error | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App Token | |
| id: app-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.AUTOMATION_APP_ID }} | |
| private-key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.release.target_commitish }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'corretto' | |
| java-version: '17' | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
| cache: 'maven' | |
| - name: Update version | |
| if: ${{ success() && github.event_name == 'release' }} | |
| run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.release.tag_name }} versions:commit | |
| - name: Publish to the Maven Central Repository | |
| if: ${{ success() && (github.event_name != 'workflow_dispatch' || inputs.dryRun != true) }} | |
| run: | | |
| mvn --batch-mode --no-transfer-progress \ | |
| -P central -DskipTests \ | |
| -Dorg.slf4j.simpleLogger.defaultLogLevel=${{ inputs.logLevel || 'info' }} \ | |
| deploy | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Commit & Push changes | |
| if: ${{ success() && github.event_name == 'release' }} | |
| uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # v1.5 | |
| with: | |
| github_token: ${{ steps.app-token.outputs.token }} | |
| message: 'Release ${{ github.event.release.tag_name }}' | |
| branch: ${{ github.event.release.target_commitish }} |