Skip to content

Publish package to the Maven Central Repository #3

Publish package to the Maven Central Repository

Publish package to the Maven Central Repository #3

Workflow file for this run

name: Publish package to the Maven Central Repository
on:
release:
types: [created]
workflow_dispatch:
inputs:
releaseVersion:
description: "Define the release version"
required: true
default: ""
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-package: 'jdk'
cache: 'maven'
server-id: ossrh
- name: Configure Git User
run: |
git config user.email "actions@github.com"
git config 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 }}" != "" ]; then
echo "auto_release=true" >> $GITHUB_ENV
else
echo "auto_release=false" >> $GITHUB_ENV
fi
- name: Publish package
run: mvn --batch-mode -Pmaven-central -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} deploy
# -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}