Publish Official Release to Maven Staging #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a package using Maven and then publish it to | |
# to our staging repo for a final release to maven central | |
# This workflow will also create a tag and github release for the current commit | |
# The github release will be have '-java' added to name to distinguish rust vs java releases | |
# Example: | |
# current version in POM.XML and in maven central = 3.1.0 | |
# tag and github release = 3.1.0-java | |
name: Publish Official Release to Maven Staging | |
defaults: | |
run: | |
working-directory: Java/ | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build project and publish release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
cache: maven | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Extract project version | |
id: project | |
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
- name: Publish to Maven central | |
if: ${{ !endsWith(steps.project.outputs.version, '-SNAPSHOT') }} | |
run: mvn -B deploy --file pom.xml -Pgpg-sign | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.project.outputs.version }}-java | |
release_name: ${{ steps.project.outputs.version }}-java | |
draft: false | |
prerelease: false |