Skip to content

chore: updated examples #41

chore: updated examples

chore: updated examples #41

Workflow file for this run

name: Publish Maven Package
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [published]
jobs:
publish-snapshot:
name: Publish Snapshot
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Get version
id: get_version
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- name: Pad run number
id: pad_run_number
run: echo "padded_run_number=$(printf '%04d' ${{ github.run_number }})" > $GITHUB_OUTPUT
- name: Set version
run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.version }}-SNAPSHOT-${{ steps.pad_run_number.outputs.padded_run_number }}
- name: Publish package
run: |
mvn -P snapshot --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-release:
name: Publish Release
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java for publishing to Maven Central
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set version
run: mvn versions:set -DnewVersion=${{ github.event.release.tag_name }}
- name: Publish package
run: |
mvn -P release --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}