Maven Release #31
This file contains 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: 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 "actions@github.com" | |
git config --global user.name "GitHub Actions" | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Import GPG Key | |
uses: crazy-max/ghaction-import-gpg@v5.0.0 | |
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: Run tests | |
run: ./mvnw -B package | |
- name: Release With Maven | |
run: | | |
./mvnw -B -U \ | |
-DskipTests \ | |
-pl '!java-to-zod-maven-plugin-test' \ | |
-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 }} |