Release on Tag #15
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: Release on Tag | |
| on: | |
| push: | |
| tags: | |
| - 'release/[0-9]*.[0-9]*.[0-9]*' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Java, Central creds and GPG | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| cache: maven | |
| server-id: central | |
| server-username: ${{ secrets.CENTRAL_USERNAME }} | |
| server-password: ${{ secrets.CENTRAL_PASSWORD }} | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#release/}" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release with notes | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| generate_release_notes: true | |
| body: | | |
| ## Docker Image | |
| Pre-built distroless container image available on GitHub Container Registry: | |
| ```bash | |
| docker pull ghcr.io/${{ github.repository_owner }}/java.util.json.java21/jdt2jar:${{ steps.version.outputs.version }} | |
| docker pull ghcr.io/${{ github.repository_owner }}/java.util.json.java21/jdt2jar:latest | |
| ``` | |
| See [jdt2jar/README.md](https://github.com/${{ github.repository }}/blob/main/jdt2jar/README.md) for usage. | |
| - name: Build and Deploy to Central (release profile) | |
| env: | |
| CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | |
| CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} | |
| run: | | |
| KN="${{ secrets.GPG_KEYNAME }}" | |
| EXTRA="" | |
| if [ -n "$KN" ]; then EXTRA="-Dgpg.keyname=$KN"; fi | |
| mvn -B -ntp -P release \ | |
| -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" \ | |
| $EXTRA \ | |
| clean deploy | |
| - name: Configure Git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Create branch from tag for PR | |
| id: prbranch | |
| run: | | |
| BRANCH_NAME="release-bot-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -B "$BRANCH_NAME" $GITHUB_SHA | |
| git push origin "$BRANCH_NAME" | |
| echo "branch=$BRANCH_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Open PR back to main | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh pr create \ | |
| --title "chore: merge release ${{ github.ref_name }} to main" \ | |
| --body "Automated PR created from tag ${{ github.ref_name }}." \ | |
| --base main \ | |
| --head "${{ steps.prbranch.outputs.branch }}" \ | |
| || echo "PR already exists or nothing to compare" | |
| docker-publish: | |
| name: Publish Docker image to GHCR | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: oracle | |
| java-version: '25' | |
| cache: 'maven' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#release/}" >> "$GITHUB_OUTPUT" | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: jdt2jar/Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/java.util.json.java21/jdt2jar:${{ steps.version.outputs.version }} | |
| ghcr.io/${{ github.repository_owner }}/java.util.json.java21/jdt2jar:latest |