Reusable GitHub Actions workflows for Maven Central publishing across markpollack repositories.
| Workflow | Purpose | Trigger |
|---|---|---|
ci-build.yml |
Build and test | Push/PR |
publish-snapshot.yml |
Deploy SNAPSHOT to Maven Central | Push to main |
maven-central-release.yml |
Release to Maven Central with GPG signing | Manual dispatch |
Add these workflow files to your repository's .github/workflows/:
name: CI Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
uses: markpollack/build-tools/.github/workflows/ci-build.yml@main
with:
java-version: '17'name: Publish Snapshot
on:
push:
branches: [main]
workflow_dispatch:
jobs:
publish:
uses: markpollack/build-tools/.github/workflows/publish-snapshot.yml@main
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 0.1.0)'
required: true
type: string
jobs:
release:
uses: markpollack/build-tools/.github/workflows/maven-central-release.yml@main
with:
version: ${{ inputs.version }}
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}Each consuming repository needs these secrets (Settings > Secrets > Actions):
| Secret | Source |
|---|---|
MAVEN_USERNAME |
Sonatype Central Portal user token (central.sonatype.com/account) |
MAVEN_PASSWORD |
Sonatype Central Portal user token password |
GPG_SECRET_KEY |
ASCII-armored GPG private key (gpg --export-secret-keys --armor <KEY_ID>) |
GPG_PASSPHRASE |
GPG key passphrase |
Consuming projects must have:
<distributionManagement>for snapshot repository<scm>sectionreleaseprofile withcentral-publishing-maven-plugin,maven-gpg-plugin,maven-source-plugin,maven-javadoc-plugin
See agent-journal for a reference POM configuration.