This guide explains how to release this library to Maven Central using the new Central Portal (OSSRH was sunset in June 2025).
- Create an account at Maven Central Portal
- Request access to the
io.github.prasanna0586namespace (if not already granted) - Generate a User Token:
- Go to Account → Generate User Token
- Save the username and token securely
You need a GPG key to sign your artifacts:
# Generate a new GPG key (if you don't have one)
gpg --gen-key
# List your keys
gpg --list-secret-keys --keyid-format=short
# Export your private key (for GitHub Actions)
gpg --armor --export-secret-keys YOUR_KEY_ID
# Publish your public key to a keyserver
gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_IDAdd the following secrets to your GitHub repository (Settings → Secrets and variables → Actions):
MAVEN_CENTRAL_USERNAME: Your Maven Central user token usernameMAVEN_CENTRAL_TOKEN: Your Maven Central user token passwordGPG_PRIVATE_KEY: Your GPG private key (output fromgpg --armor --export-secret-keys YOUR_KEY_ID)GPG_PASSPHRASE: Your GPG key passphrase
Note: The actions/setup-java@v5 action automatically configures Maven's settings.xml with these credentials and sets up GPG signing. You don't need to manually configure anything else.
Create or update ~/.m2/settings.xml:
<settings>
<servers>
<server>
<id>central</id>
<username>YOUR_MAVEN_CENTRAL_TOKEN_USERNAME</username>
<password>YOUR_MAVEN_CENTRAL_TOKEN_PASSWORD</password>
</server>
</servers>
</settings>Before doing an actual release, it's recommended to test the publishing pipeline with a snapshot deployment.
-
Ensure your version ends with
-SNAPSHOT(e.g.,7.0.1-SNAPSHOT) -
Go to Actions tab → "Run Snapshot Deploy" workflow
-
Click "Run workflow"
-
This will:
- Run all tests
- Build artifacts (JAR, sources, javadoc)
- Sign with GPG
- Deploy to Maven Central snapshot repository
- Does NOT create any release or tags
-
Verify the snapshot appears at:
What this tests:
- ✅ Maven Central authentication
- ✅ GPG signing
- ✅ Source and Javadoc JAR generation
- ✅ Artifact upload
- ✅ All release plugins work correctly
What this does NOT do:
- ❌ Create git tags
- ❌ Modify version numbers
- ❌ Create an official release
Once the snapshot deployment succeeds, you can proceed with confidence to either a release candidate or the actual release.
Common issues and solutions:
GPG Signing Fails:
- Verify
GPG_PRIVATE_KEYsecret is correctly set - Verify
GPG_PASSPHRASEsecret matches your key - Check your GPG key is published:
gpg --keyserver keyserver.ubuntu.com --recv-keys YOUR_KEY_ID
Maven Central Authentication Fails:
- Verify
MAVEN_CENTRAL_USERNAMEandMAVEN_CENTRAL_TOKENare correct - Test credentials at https://central.sonatype.com/
- Ensure you have access to the
io.github.prasanna0586namespace
Tests Fail:
- Fix the tests before proceeding
- The release will also fail if tests fail
Use this for major version bumps, breaking changes, or when testing a new release process.
-
Go to Actions tab → "Release Candidate" workflow
-
Click "Run workflow"
-
Enter RC number (e.g.,
1for RC1,2for RC2) -
This will:
- Validate the RC doesn't already exist
- Create release
7.0.1-RC1from7.0.1-SNAPSHOT - Publish to Maven Central
- Create git tag
v7.0.1-RC1 - Reset back to
7.0.1-SNAPSHOT
-
Manually create a GitHub Release:
- Go to the provided URL in the workflow output
- Mark as "pre-release"
- Add release notes explaining what's being tested
-
Test the RC in your projects
-
If issues found: Fix them, then run RC2
-
If all good: Proceed to final release
Example workflow:
7.0.1-SNAPSHOT
↓
RC1 (test) → Found bugs
↓
Fix bugs in 7.0.1-SNAPSHOT
↓
RC2 (test) → All good!
↓
Final release 7.0.1
↓
7.0.2-SNAPSHOT
Use this for bug fixes, minor improvements, or well-tested changes.
- Go to Actions tab in GitHub
- Select "Release to Maven Central" workflow
- Click "Run workflow"
- (Optional) Override versions:
- Leave empty to use automatic versioning (recommended)
- Or specify custom release version (e.g.,
7.1.0for minor version bump) - Or specify custom next development version (e.g.,
7.1.1-SNAPSHOT)
- Click "Run workflow"
Automatic versioning (when inputs are empty):
- Current:
7.0.1-SNAPSHOT→ Release:7.0.1→ Next:7.0.2-SNAPSHOT - Current:
7.0.1-SNAPSHOT→ Release:7.0.1→ Next:7.1.0-SNAPSHOT(minor bump)
The workflow will:
- Automatically determine versions from pom.xml (if not specified)
- Run all tests
- Create a release tag
- Build and sign artifacts
- Deploy to Maven Central
- Update version to next development version
# Ensure everything is committed
git status
# Run the release
mvn release:prepare release:perform
# You'll be prompted for:
# - Release version (default: removes -SNAPSHOT)
# - SCM tag name (default: v{version})
# - Next development version (default: increments and adds -SNAPSHOT)The release profile (activated by maven-release-plugin) includes:
- central-publishing-maven-plugin: Publishes to Maven Central Portal (replaces deprecated nexus-staging-maven-plugin)
- maven-gpg-plugin: Signs all artifacts with your GPG key
- maven-source-plugin: Creates source JAR
- maven-javadoc-plugin: Creates Javadoc JAR
If you get "gpg: signing failed: Inappropriate ioctl for device":
export GPG_TTY=$(tty)If release:prepare fails, rollback and try again:
mvn release:rollbackCheck your deployment status at:
Follow Semantic Versioning:
- MAJOR.MINOR.PATCH (e.g., 7.0.1)
- Development versions end with
-SNAPSHOT(e.g., 7.0.2-SNAPSHOT)
After a successful release:
- Check Maven Central for the new version (may take a few hours to sync)
- Create a GitHub Release with release notes
- Update documentation if needed