Release artifact to Maven Central Repository #62
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: Release artifact to Maven Central Repository | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: "Release version" | |
required: true | |
default: "X.Y.Z" | |
developmentVersion: | |
description: "Next snapshot version" | |
required: true | |
default: "X.Y.Z-SNAPSHOT" | |
jobs: | |
release: | |
name: Release to Maven Central | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.REPO_SSH_PRIVATE_KEY }} | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'oracle' | |
java-version: '22' | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_TOKEN | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
cache: 'maven' | |
- name: Configure git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
- name: Maven Prepare Release | |
run: mvn --batch-mode release:clean release:prepare -Dtag=v${{ github.event.inputs.releaseVersion }} -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} | |
env: | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- uses: webfactory/ssh-agent@v0.8.0 | |
name: Set SSH key | |
with: | |
ssh-private-key: ${{ secrets.REPO_SSH_PRIVATE_KEY }} | |
- name: Maven Release | |
run: mvn --batch-mode release:perform | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |