When you create and publish a GitHub Release, the release.yml workflow automatically:
- Builds the project with Maven
- Generates source and Javadoc JARs
- Signs all artifacts with GPG
- Deploys to Maven Central via the Sonatype Central Portal (OSSRH Staging API)
- Automatically releases the staging repository
Artifacts typically appear on Maven Central within 10–30 minutes after deployment.
These steps only need to be done once (or when credentials expire/rotate).
The com.drewnoakes namespace was migrated from OSSRH to the Central Portal.
- Go to https://central.sonatype.com/ and sign in
- Use the same username/password you used for the old OSSRH
- If you can't log in, contact central-support@sonatype.com to recover access
- Verify your namespace at https://central.sonatype.com/publishing/namespaces
— you should see
com.drewnoakes - Go to https://central.sonatype.com/usertoken
- Click Generate User Token, give it a name and expiration
- Save both values (username token + password token) — they cannot be retrieved later
Maven Central requires all artifacts to be GPG-signed.
# Generate a new key (choose RSA 4096-bit, use your email)
gpg --full-generate-key
# List keys to find your key ID
gpg --list-secret-keys --keyid-format long
# Output looks like:
# sec rsa4096/ABC123DEF456 2024-01-01 [SC]
# The key ID is the part after the slash (ABC123DEF456)
# Export the private key (ASCII armored)
gpg --armor --export-secret-keys ABC123DEF456 > private-key.asc
# Publish the public key to keyservers (required by Maven Central for verification)
gpg --keyserver keyserver.ubuntu.com --send-keys ABC123DEF456
gpg --keyserver keys.openpgp.org --send-keys ABC123DEF456If you have a GPG key from previous releases:
# List your existing keys
gpg --list-secret-keys --keyid-format long
# Export it
gpg --armor --export-secret-keys YOUR_KEY_ID > private-key.ascGo to the repository on GitHub → Settings → Secrets and variables → Actions, and add these four repository secrets:
| Secret Name | Value |
|---|---|
OSSRH_USERNAME |
Your Central Portal user token username (from step 1.5) |
OSSRH_TOKEN |
Your Central Portal user token password (from step 1.5) |
GPG_PRIVATE_KEY |
The full contents of private-key.asc (including the -----BEGIN PGP PRIVATE KEY BLOCK----- header and footer lines) |
GPG_PASSPHRASE |
The passphrase you chose when creating the GPG key |
After adding the secrets, delete the exported key file from your local machine:
rm private-key.asc-
Create a GitHub Release:
- Go to https://github.com/drewnoakes/metadata-extractor/releases/new
- Tag:
2.20.0(create new tag on publish) - Title:
2.20.0 - Add release notes (or click "Generate release notes")
- Click Publish release
-
The release workflow triggers automatically and uses the tag name as the version. No version needs to be committed in source code — the tag is the single source of truth.
-
Monitor progress in the Actions tab.
- Go to the Actions tab on GitHub
- Click the running "Publish to Maven Central" workflow
- The
Publish to Maven Centralstep logs show:- Build and test output
- GPG signing of each artifact
- Upload to the Sonatype staging repository
- Staging repository close and release
Allow 10–30 minutes after a successful workflow run, then:
- Visit https://central.sonatype.com/artifact/com.drewnoakes/metadata-extractor and verify the new version appears
- Or check the raw repository: https://repo1.maven.org/maven2/com/drewnoakes/metadata-extractor/
Create a temporary test project to verify the artifact resolves correctly.
Create a file called pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test-metadata-extractor</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.20.0</version>
</dependency>
</dependencies>
</project>Then run:
mvn dependency:resolveIf it downloads the expected version, the release is live.
Before your first real release, validate the pipeline using the manual workflow trigger:
- Go to Actions → Publish to Maven Central → Run workflow
- Leave the version field empty for a timestamped SNAPSHOT (e.g.
0.0.0-20260408120000-SNAPSHOT), or enter a test version like2.20.0-rc1 - SNAPSHOT versions go to the snapshots repository (not Maven Central releases), so this is safe to experiment with
- Watch the logs to confirm build, signing, and upload all succeed
- Sonatype credentials are wrong or expired
- You must use a Central Portal token, not old OSSRH credentials
- Generate a new token at https://central.sonatype.com/usertoken
- Update the
OSSRH_USERNAMEandOSSRH_TOKENGitHub secrets
- Verify
GPG_PRIVATE_KEYcontains the complete armored key (including-----BEGIN PGP PRIVATE KEY BLOCK-----and-----END PGP PRIVATE KEY BLOCK-----) - Verify
GPG_PASSPHRASEis correct - If signing still fails in CI, try upgrading
maven-gpg-pluginfrom1.6to3.2.7inpom.xml— newer versions handle CI environments (non-interactive GPG agent) more reliably
Sonatype enforces rules before releasing to Maven Central:
- All artifacts must have source and Javadoc JARs ✅ (already configured)
- All artifacts must be GPG-signed ✅ (configured via workflow)
- POM must include required metadata ✅ (name, description, URL, license, SCM, developers — all present)
If rules fail, check your deployments at https://central.sonatype.com/publishing for specific error messages.
- Allow up to 30 minutes for sync after a successful deploy
- Check https://repo1.maven.org/maven2/com/drewnoakes/metadata-extractor/
- Verify the workflow log shows the staging repository was released (not just closed)

