Skip to content

Maven Release

Maven Release #30

Workflow file for this run

name: Maven Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Release version"
required: true
default: ""
developmentVersion:
description: "Next snapshot version (without -SNAPSHOT suffix)"
required: true
default: ""
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Configure Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Import GPG Key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Verify Whether a Release is Ready
id: release
shell: bash
run: |
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
echo "auto_release=true" >> $GITHUB_ENV
else
echo "auto_release=false" >> $GITHUB_ENV
fi
- name: Release With Maven
run: |
./mvnw -B -U \
-Pci-cd \
release:prepare \
release:perform \
-s settings.xml \
-Dgpg.passphrase='${{ secrets.MAVEN_GPG_PASSPHRASE }}' \
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}-SNAPSHOT \
deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SKIP_SITE: true
- name: Deploy site
run: |
git checkout "v${{ github.event.inputs.releaseVersion }}" && \
./mvnw -B -U -Pci-cd site site:stage scm-publish:publish-scm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}