|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + skip-deploy-maven-central: |
| 7 | + description: "Skip deployment to Maven Central" |
| 8 | + required: true |
| 9 | + type: boolean |
| 10 | + default: false |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + shell: "bash" |
| 18 | + concurrency: |
| 19 | + group: ${{ github.workflow }} |
| 20 | + cancel-in-progress: false |
| 21 | + permissions: |
| 22 | + contents: write # Required for creating GitHub release |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Fail if not running on main branch |
| 28 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 29 | + uses: actions/github-script@v7 |
| 30 | + with: |
| 31 | + script: | |
| 32 | + core.setFailed('Not running on main branch, github.ref is ${{ github.ref }}. Please start this workflow only on main') |
| 33 | +
|
| 34 | + - name: Set up Maven Central Repository |
| 35 | + uses: actions/setup-java@v4 |
| 36 | + with: |
| 37 | + distribution: "temurin" |
| 38 | + java-version: 17 |
| 39 | + cache: "maven" |
| 40 | + server-id: ossrh |
| 41 | + server-username: MAVEN_USERNAME |
| 42 | + server-password: MAVEN_PASSWORD |
| 43 | + gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} |
| 44 | + gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 45 | + |
| 46 | + - name: Build |
| 47 | + run: mvn --batch-mode -T 1C clean install |
| 48 | + |
| 49 | + - name: List secret GPG keys |
| 50 | + run: gpg --list-secret-keys |
| 51 | + |
| 52 | + - name: Publish to Maven Central Repository |
| 53 | + if: ${{ !inputs.skip-deploy-maven-central }} |
| 54 | + run: mvn --batch-mode deploy -Possrh -DstagingDescription="Deployed via GitHub workflow release.yml" |
| 55 | + env: |
| 56 | + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} |
| 57 | + MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} |
| 58 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} |
| 59 | + |
| 60 | + - name: Create GitHub Release |
| 61 | + run: ./.github/workflows/github_release.sh |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ github.token }} |
0 commit comments