Release project to Maven central #36
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 project to Maven central | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: "Default version to use when preparing a release." | |
required: true | |
default: "X.Y.Z" | |
developmentVersion: | |
description: "Default version to use for new local working copy." | |
required: true | |
default: "X.Y.Z-SNAPSHOT" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Setup Java JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 8 | |
distribution: temurin | |
cache: maven | |
server-id: github | |
- name: Configure Git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
- name: Publish JAR | |
run: mvn -B release:clean release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: v${{ github.event.inputs.releaseVersion }} | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 8 | |
distribution: temurin | |
cache: maven | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Configure Git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
- name: Release and publish to the Maven Central Repository | |
run: | | |
mvn \ | |
--no-transfer-progress \ | |
--batch-mode \ | |
deploy -Pbuild | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} |