Skip to content

Workflow file for this run

name: Publish package to the Maven Central Repository
on:
release:
types: [created]
jobs:
deploy:
if: ${{ github.ref_type == 'tag' }}
name: Deploy
runs-on: ubuntu-latest
environment: deploy
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.PGP_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Get version from maven + tag and fail on version mismatch
run: |
MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "MVN_VERSION: $MVN_VERSION"
if [[ "$MVN_VERSION" != "${{ github.ref_name }}" ]]; then exit 1; fi
- name: Build and Deploy with Maven
run: mvn -B -P sign-artifacts deploy --no-transfer-progress
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}