Skip to content

Release Workflow

Release Workflow #50

Workflow file for this run

name: Release Workflow
on:
workflow_dispatch:
inputs:
release-version:
description: 'Version being released'
required: true
snapshot-version:
description: 'Next snapshot version'
required: true
branch:
description: 'Branch to release from'
required: true
default: 'main'
jobs:
release:
runs-on: ubuntu-latest
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
if: github.repository_owner == 'Apicurio'
steps:
- name: 'Checkout'
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch}}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
- name: Log Metadata
run: |
echo "Releasing Apicurio Codegen version ${{ github.event.inputs.release-version }} from branch ${{ github.event.inputs.branch }}"
echo "Next Snapshot version will be ${{ github.event.inputs.snapshot-version }}"
- name: Set up settings.xml
run: |
echo "<settings><servers><server><id>central</id><username>${{ secrets.CENTRAL_USERNAME }}</username><password>${{ secrets.CENTRAL_TOKEN }}</password></server></servers><profiles><profile><id>central</id><activation><activeByDefault>true</activeByDefault></activation><properties><gpg.executable>gpg</gpg.executable></properties></profile></profiles></settings>" > /home/runner/.m2/settings.xml
cat /home/runner/.m2/settings.xml
- name: Configure Git
run: |
git init
git config --global user.name "apicurio-ci"
git config --global user.email "apicurio.ci@gmail.com"
git branch --set-upstream-to=origin/${{ github.event.inputs.branch}}
git pull
echo "#### Listing files ####"
find .
# To avoid permission denied issues
- name: Give full Permissions
run: chmod -R 777 $(pwd)
- name: Update Release Version ${{ github.event.inputs.release-version }}
run: ./mvnw versions:set -DnewVersion=${{ github.event.inputs.release-version }} -DgenerateBackupPoms=false -DprocessAllModules=true
- name: Verify Build
run: ./mvnw clean install
- name: Commit Release Version Change
run: |
git add .
git commit -m "Automated version update: ${{ github.event.inputs.release-version}}"
git push
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Maven Deploy
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 5
retry_on: any
retry_wait_seconds: 120
command: ./mvnw deploy -Prelease --batch-mode --settings /home/runner/.m2/settings.xml -DskipTests
- name: Slack Notification (Always)
if: always()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}
- name: Slack Notification (Error)
if: failure()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}
set-next-snapshot:
needs: release
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch}}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
- name: Update Snapshot version ${{ github.event.inputs.snapshot-version}}
run: ./mvnw versions:set -DnewVersion=${{ github.event.inputs.snapshot-version}} -DgenerateBackupPoms=false -DprocessAllModules=true
- name: Configure Git
run: |
git init
git config --global user.name "apicurio-ci"
git config --global user.email "apicurio.ci@gmail.com"
git branch --set-upstream-to=origin/${{ github.event.inputs.branch}}
git pull
echo "#### Listing files ####"
find .
- name: Commit Snapshot Version Change
run: |
git add .
git commit -m"Automated version update: ${{ github.event.inputs.snapshot-version}}"
git push
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.release-version}}
- uses: lakto/gren-action@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
options: '--override'
- name: Slack Notification (Error)
if: failure()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}