Skip to content

Publish to the Maven Central #10

Publish to the Maven Central

Publish to the Maven Central #10

Workflow file for this run

name: Publish to the Maven Central
on:
workflow_dispatch:
push:
branches:
- snapshot
tags:
- '*'
jobs:
oss-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Cache local Maven repository
uses: actions/[email protected]
env:
cache-name: cache-mvn
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# - name: Build with Maven
# run: mvn -B package --file pom.xml
# - name: Publish to GitHub Packages Apache Maven
# run: mvn deploy
# env:
# GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
- name: Import GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_KEY }}
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Publish to Maven Central
run: ./mvnw --settings ./ossrh-settings.xml clean deploy -Dgpg.passphrase=${MAVEN_GPG_PASSPHRASE} -DskipTests=true -P 'oss-release'
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
OSSRH_USERNAME: ${{ secrets.OSSRH_TOKEN_USER }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_PWD }}