Deploy Maven Release #2
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 Maven Release | |
| on: | |
| workflow_dispatch: {} | |
| release: | |
| types: [published] | |
| concurrency: | |
| group: release | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| env: | |
| GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: maven | |
| gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} | |
| - name: Test with Maven | |
| run: mvn --batch-mode test verify --file pom.xml | |
| build: | |
| runs-on: ubuntu-24.04 | |
| needs: test | |
| environment: | |
| name: release | |
| url: ${{ steps.deployment.outputs.url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: maven | |
| gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} | |
| - name: Set GitHub Credentials | |
| run: | | |
| git config --global user.name "Coderic" | |
| git config --global user.email "coderic@coderic.org" | |
| - name: Build package | |
| run: mvn --batch-mode package --file pom.xml | |
| - name: Prepare package | |
| run: mvn --batch-mode release:prepare -DtagNameFormat=@{project.version} --file pom.xml | |
| - name: Deploy package | |
| id: deployment | |
| run: mvn --batch-mode release:perform -DtagNameFormat=@{project.version} --file pom.xml | |
| deploy: | |
| runs-on: ubuntu-24.04 | |
| environment: | |
| name: staging | |
| url: ${{ steps.deployment.outputs.url }} | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: sed -i 's|http://localhost:8080/|${{ secrets.TOMCAT_HOST }}|g' pom.xml | |
| - name: Set up Maven Central Repository | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: maven | |
| server-id: TomcatServer | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} | |
| - name: Deploy package | |
| run: mvn --batch-mode tomcat7:deploy --file pom.xml | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.TOMCAT_USER }} | |
| MAVEN_PASSWORD: ${{ secrets.TOMCAT_PASS }} |