Skip to content

Release to Maven Central #14

Release to Maven Central

Release to Maven Central #14

Workflow file for this run

name: Release to Maven Central
env:
MAVEN_ARGS: -V -ntp -e
on:
release:
types: [ released ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Java and Maven
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'maven'
- name: change version to release version
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
maven_profiles: "release"
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}
# This is separate job because there were issues with git after release step, was not able to commit changes. See history.
update-working-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Java and Maven
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'maven'
- name: change version to release version
run: |
./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Set new SNAPSHOT version into pom files." -a
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}