Change error handling to log instead of raise for top level role appl… #96
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: Deploy to Maven Central | |
| on: | |
| push: | |
| branches: | |
| # Build Snapshots From Main | |
| - main | |
| - release/* | |
| tags: | |
| # Build Releases From Tags | |
| - v*.*.* | |
| permissions: | |
| contents: read | |
| jobs: | |
| get-version: | |
| environment: deploy | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| deploy: ${{ steps.determine-deploy.outputs.deploy }} | |
| release: ${{ steps.determine-deploy.outputs.release }} | |
| java-version: ${{ steps.set-constants.outputs.java-version }} | |
| java-distribution: ${{ steps.set-constants.outputs.java-distribution }} | |
| steps: | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Set Constants | |
| id: set-constants | |
| run: | | |
| echo "java-version=17" >> $GITHUB_OUTPUT | |
| echo "java-distribution=temurin" >> $GITHUB_OUTPUT | |
| - name: Set up JDK | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| java-version: ${{ steps.set-constants.outputs.java-version }} | |
| distribution: ${{ steps.set-constants.outputs.java-distribution }} | |
| cache: maven | |
| - name: Extract Maven project version | |
| run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | |
| id: get-version | |
| - name: Determine if Deploy | |
| id: determine-deploy | |
| # We want to build releases from tags matching the correct pattern and matching the pom version. | |
| # We want to build snapshot releases from any push to main. | |
| uses: actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325 # v6 | |
| env: | |
| VERSION: ${{ steps.get-version.outputs.version }} | |
| REF: ${{ github.ref }} | |
| with: | |
| script: | | |
| const versionPattern = /[0-9]+\.[0-9]+\.[0-9]/; | |
| const snapshotPattern = /[0-9]+\.[0-9]+\.[0-9]-SNAPSHOT/; | |
| const REF = process.env.REF; | |
| const VERSION = process.env.VERSION; | |
| if (`refs/tags/v${VERSION}` === REF && versionPattern.test(VERSION)) { | |
| core.setOutput('deploy', true); | |
| core.setOutput('release', true); | |
| } else if (snapshotPattern.test(VERSION)) { | |
| core.setOutput('deploy', true); | |
| core.setOutput('release', false); | |
| } else { | |
| core.setOutput('deploy', false); | |
| core.setOutput('release', false); | |
| } | |
| deploy-maven: | |
| environment: deploy | |
| runs-on: ubuntu-latest | |
| needs: get-version | |
| if: ${{ fromJSON(needs.get-version.outputs.deploy) }} | |
| steps: | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Set up Maven Central Repository | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| java-version: ${{ needs.get-version.outputs.java-version }} | |
| distribution: ${{ needs.get-version.outputs.java-distribution }} | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| cache: maven | |
| - id: install-secret-key | |
| name: Install gpg secret key | |
| run: | | |
| # Install gpg secret key | |
| cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import | |
| # Verify gpg secret key | |
| gpg --list-secret-keys --keyid-format LONG | |
| - name: Publish package | |
| run: mvn -Ppublish --batch-mode -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} clean deploy | |
| env: | |
| MAVEN_USERNAME: ${{ vars.OSSRH_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} |