Skip to content

Java with Maven

Java with Maven #11

# This workflow will publish AMaaS Java SDK to Maven Central with OSSRH
name: Java with Maven
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# Setup Envvar for build
- name: Set env
run: |
if [[ "${{ github.ref }}" == "refs/tags/v"* ]];
then
echo "PACK_CMD=deploy" >> $GITHUB_ENV
else
echo "PACK_CMD=package" >> $GITHUB_ENV
fi
# package and optionally publish Java SDK to Maven Central
- name: Package and optionally deploy with Maven
run: |
mvn -B clean ${{env.PACK_CMD}}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}