Skip to content

Release

Release #18

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
target-branch:
description: "Branch to release"
required: true
type: choice
default: 'main'
options:
- "main"
- "2.2"
- "2.1"
- "1.0"
version:
description: "Version to release (e.g. 1.1.0 or 1.2.0-alpha1)"
required: true
type: string
dry-run:
description: "Dry run (skips remote operations)"
required: true
type: boolean
default: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
username: ${{github.triggering_actor}}
check-contributor: true
require: 'write'
- name: Fail on workflow triggered by external contributor
if: ${{ steps.checkUser.outputs.require-result != 'true' }}
run: |
echo "🚫 **${{ github.actor }}** is an external contributor, only **${{ github.repository }}** team members can perform a release" \
| tee -a $GITHUB_STEP_SUMMARY && exit 1
- name: Validate Workflow branch
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "main" != "${BRANCH_NAME}" ]]; then
echo "🚫 Release Workflow must be dispatched on 'main' branch." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: refs/heads/${{ inputs.target-branch }}
fetch-depth: 0
- name: Validate version
run: |
VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)[0-9]+)?$'
if [[ ! "${{ inputs.version }}" =~ $VERSION_REGEX ]]; then
echo "🚫 Invalid version specified: '${{ inputs.version }}'. Please enter a valid SemVer version, like '1.2.3' or '1.0.0-alpha1'." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
if [[ "${{ inputs.target-branch }}" != "main" && ! "${{ inputs.version }}" = "${{ inputs.target-branch }}."* ]]; then
echo "ERROR: Invalid version specified: '${{ inputs.version }}' does not match the release branch '${{ inputs.target-branch }}'." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
if git rev-parse -q --verify "refs/tags/${{ inputs.version }}" > /dev/null; then
echo "🚫 Version '${{ inputs.version }}' already exists. Please choose a different version." \
| tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
echo "Releasing version '${{ inputs.version }}' from branch '${{ inputs.target-branch }}'." >> $GITHUB_STEP_SUMMARY
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Staging artifacts
run: |
mvn -V -ntp -Pdistribution,default-modules -Drevision=${{ inputs.version }} -DaltDeploymentRepository=local::file:./target/staging-deploy deploy
- name: Run JReleaser
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_DEPLOY_MAVEN_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_TOKEN }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
run: |
mvn -N -V -ntp -Pdistribution -Drevision=${{ inputs.version }} -Djreleaser.dry.run="${{ github.event.inputs.dry-run }}" jreleaser:full-release
- name: JReleaser release output
if: always()
uses: actions/upload-artifact@v3
with:
name: jreleaser-release
path: |
target/jreleaser/trace.log
target/jreleaser/output.properties