Configure Release Secrets
October 12, 2025 · View on GitHub
This guide explains how to configure the GitHub secrets required to publish releases to Maven Central and sign artifacts.
The release workflow reads the following secrets:
CENTRAL_USERNAME— Sonatype (OSSRH) usernameCENTRAL_PASSWORD— Sonatype (OSSRH) passwordGPG_PRIVATE_KEY— ASCII‑armored GPG private key used for signingGPG_PASSPHRASE— Passphrase for the above private key
Prerequisites:
- A Sonatype (OSSRH) account with publishing permissions for this groupId
- A GPG keypair suitable for signing (RSA/ECC)
Steps:
-
Export your GPG private key in ASCII‑armored form
- List keys:
gpg --list-secret-keys --keyid-format LONG - Export:
gpg --armor --export-secret-keys <KEY_ID> > private.key.asc
- List keys:
-
Add repository secrets
- Open GitHub → Settings → Secrets and variables → Actions → New repository secret
- Add the following secrets:
CENTRAL_USERNAME— your Sonatype usernameCENTRAL_PASSWORD— your Sonatype passwordGPG_PRIVATE_KEY— contents ofprivate.key.ascGPG_PASSPHRASE— your GPG key passphrase
-
Verify workflow configuration
- The workflow
.github/workflows/release.ymlverifies that all four secrets are present - It configures Maven settings and GPG using
actions/setup-java@v4
- The workflow
-
Trigger a release
- Tag the repo:
git tag v<version>where<version>matches the POM version - Push the tag:
git push origin v<version> - The workflow validates tag/version parity and publishes artifacts if tests pass
- Tag the repo:
Troubleshooting:
- Missing secret: the workflow fails early with a clear error message
- GPG key format: ensure the key is ASCII‑armored, not binary
- Staging errors on Central: check Sonatype UI for staging repository status