Skip to content

Replace test workflow with CI & Publish workflow #1

Replace test workflow with CI & Publish workflow

Replace test workflow with CI & Publish workflow #1

Workflow file for this run

name: CI & Publish
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 25 (Azul Zulu)
if: "!startsWith(github.ref, 'refs/tags/v')"
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '25'
cache: maven
- name: Set up JDK 25 (Azul Zulu) for Maven Central
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '25'
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Set release version from tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "Publishing version: $VERSION"
mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false
- name: Build and test
run: mvn verify
- name: Publish to Maven Central
if: startsWith(github.ref, 'refs/tags/v')
run: mvn deploy -Prelease -DskipTests
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}