Skip to content

Publish package to the Maven Central Repository #85

Publish package to the Maven Central Repository

Publish package to the Maven Central Repository #85

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Publish package to the Maven Central Repository
on:
workflow_dispatch:
inputs:
git-ref:
description: 'The branch, tag or SHA to checkout'
required: true
default: 'v2.x.y or master'
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- run: |
echo "Release ref: ${{ github.event.inputs.git-ref }}"
- name: Git checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Cache node modules
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Cache node install
uses: actions/cache@v3
with:
path: 'node_install'
key: ${{ runner.os }}-node_install-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-node_install-
- name: Set Publish Environment
uses: actions/setup-java@v3
with:
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: Set JAVA_HOME
run: |
echo "JAVA_8_HOME=$JAVA_HOME_8_X64" >> $GITHUB_ENV
echo "JAVA_11_HOME=$JAVA_HOME_11_X64" >> $GITHUB_ENV
echo "JAVA_17_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
echo "JAVA_HOME=$JAVA_HOME_8_X64" >> $GITHUB_ENV
- name: Java Environment
run: env | grep '^JAVA'
- name: Publish package
run: ./mvnw --batch-mode deploy --file pom.xml -P '!it-module,!agent-testweb-module' -DskipTests=true -Pmaven.central.release
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}