Maven Package Release #32
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 Package Release | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: "Release version" | |
required: true | |
default: "" | |
developmentVersion: | |
description: "Snapshot version" | |
required: true | |
default: "" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
java-package: 'jdk' | |
cache: 'maven' | |
server-id: central | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_PASSWORD | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: SIGN_KEY_PASS | |
- 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: Configure Git User | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
- name: Verify | |
run: | | |
mvn -Prelease verify -Dgpg.skip | |
- name: Release With Maven | |
run: | | |
export GPG_TTY=$(tty) | |
mvn -B --file pom.xml -DskipTests release:prepare release:perform \ | |
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ | |
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} | |
env: | |
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OSSRH_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
OSSRH_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |