Skip to content

Create main.yml

Create main.yml #1

Workflow file for this run

name: Release to Maven Central
on:
push:
branches:
- main
jobs:
build-and-release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Import GPG signing key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.MAVEN_SIGNING_KEY }}
passphrase: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }}
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Calculate version
id: calculate-version
uses: bitshifted/git-auto-semver@v1
with:
create_tag: true
- name: Build and Test
run: |
# Replace with your build and test commands
./mvnw clean verify
- name: Release to Maven repo
if: success() # Only run if previous steps were successful
run: |
mvn -P release -Dgpg.keyname=${{ secrets.GPG_KEY_NAME }} \
-Dgpg.passphrase=${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} \
-Drevision=${{ steps.calculate-version.outputs.version-string }} deploy
env:
MVN_CENTRAL_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
MVN_CENTRAL_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}