|
| 1 | +name: Publish to the Maven Central Repository |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [ published ] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + dryRun: |
| 9 | + description: "Dry-Run (skip deploy and push-back)" |
| 10 | + default: false |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + logLevel: |
| 14 | + description: "Log-Level" |
| 15 | + required: false |
| 16 | + default: 'info' |
| 17 | + type: choice |
| 18 | + options: |
| 19 | + - info |
| 20 | + - warn |
| 21 | + - debug |
| 22 | + - error |
| 23 | + |
| 24 | +jobs: |
| 25 | + publish: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Generate GitHub App Token |
| 29 | + id: app-token |
| 30 | + uses: actions/create-github-app-token@v1 |
| 31 | + with: |
| 32 | + app-id: ${{ secrets.AUTOMATION_APP_ID }} |
| 33 | + private-key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }} |
| 34 | + |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v6 |
| 37 | + with: |
| 38 | + ref: ${{ github.event.release.target_commitish }} |
| 39 | + token: ${{ steps.app-token.outputs.token }} |
| 40 | + |
| 41 | + - name: Set up JDK |
| 42 | + uses: actions/setup-java@v5 |
| 43 | + with: |
| 44 | + distribution: 'corretto' |
| 45 | + java-version: '17' |
| 46 | + server-id: central |
| 47 | + server-username: MAVEN_USERNAME |
| 48 | + server-password: MAVEN_PASSWORD |
| 49 | + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 50 | + gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 51 | + cache: 'maven' |
| 52 | + |
| 53 | + - name: Update version |
| 54 | + if: ${{ success() && github.event_name == 'release' }} |
| 55 | + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.release.tag_name }} versions:commit |
| 56 | + |
| 57 | + - name: Publish to the Maven Central Repository |
| 58 | + if: ${{ success() && (github.event_name != 'workflow_dispatch' || inputs.dryRun != true) }} |
| 59 | + run: | |
| 60 | + mvn --batch-mode --no-transfer-progress \ |
| 61 | + -P central -DskipTests \ |
| 62 | + -Dorg.slf4j.simpleLogger.defaultLogLevel=${{ inputs.logLevel || 'info' }} \ |
| 63 | + deploy |
| 64 | + env: |
| 65 | + MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 66 | + MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }} |
| 67 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 68 | + |
| 69 | + - name: Commit & Push changes |
| 70 | + if: ${{ success() && github.event_name == 'release' }} |
| 71 | + uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # v1.5 |
| 72 | + with: |
| 73 | + github_token: ${{ steps.app-token.outputs.token }} |
| 74 | + message: 'Release ${{ github.event.release.tag_name }}' |
| 75 | + branch: ${{ github.event.release.target_commitish }} |
0 commit comments