This guide explains how to publish the
tomcat-maven-plugin to Maven Central via Sonatype
OSSRH.
This project follows GitHub Flow, a lightweight branch-based workflow:
main - The single long-lived branch,
always in a deployable statefeature/add-hot-deploy,
fix/port-conflict)Create a feature branch from
main:
git checkout main
git pull origin main
git checkout -b feature/your-feature-nameMake changes and commit frequently:
git add .
git commit -m "Add feature description"Push and create a Pull Request:
git push -u origin feature/your-feature-namemainMerge after review - PR merges into
main after approval and CI passes
Release from main - Create a
GitHub Release to publish to Maven Central
| Workflow | Trigger | Purpose |
|---|---|---|
ci.yml |
Push to main, PRs to main |
Build, test, code quality checks |
publish.yml |
GitHub Release publish | Deploy to Maven Central |
gh-pages.yml |
Push to main (docs changes) |
Deploy documentation site |
wiki-sync.yml |
Push to main (wiki changes) |
Sync wiki to GitHub Wiki |
codeql.yml |
Push/PR to main, weekly |
Security and code quality analysis |
The project documentation is hosted at: https://rajendarreddyj.github.io/tomcat-maven-plugin/
The gh-pages.yml workflow automatically deploys: -
Landing page with quick start guide - Javadoc API documentation -
Plugin documentation
Setup GitHub Pages: 1. Go to Settings → Pages 2.
Source: “GitHub Actions” 3. The workflow deploys automatically on
pushes to main
User guide and tutorials are available in the Wiki:
| Page | Description |
|---|---|
| Getting Started | Installation and first steps |
| Configuration | All configuration parameters |
| Goals Reference | Detailed goal documentation |
| Debugging | Debug your application |
| Hot Deployment | Auto-publish on file changes |
| Troubleshooting | Common issues and solutions |
| FAQ | Frequently asked questions |
Updating the Wiki:
Wiki content is maintained in the wiki/ directory and
automatically synced to GitHub Wiki.
wiki/ directorymain branchwiki-sync.yml workflow automatically syncs
changes to GitHub WikiManual sync (if needed):
git clone https://github.com/rajendarreddyj/tomcat-maven-plugin.wiki.git
cp -r wiki/* tomcat-maven-plugin.wiki/
cd tomcat-maven-plugin.wiki
git add .
git commit -m "Update wiki"
git pushOr edit directly in GitHub Wiki web interface (changes won’t sync back to main repo).
Prerequisites: - Wiki must be initialized first
(create any page via GitHub Wiki UI) - The workflow uses
GITHUB_TOKEN which has wiki write permissions by
default
The entire publishing process is automated via GitHub Actions. Once configured, publishing requires only creating a GitHub Release.
When you publish a GitHub Release, the publish.yml
workflow automatically:
v prefix)The workflow automatically generates release notes containing: - All commits since the previous tag - Link to full changelog comparison
Example output:
## What's Changed
- Add hot deploy feature (a1b2c3d)
- Fix port conflict detection (e4f5g6h)
- Update dependencies (i7j8k9l)
**Full Changelog**: https://github.com/rajendarreddyj/tomcat-maven-plugin/compare/v0.9.0...v1.0.0Ensure main is ready - all
features merged, tests passing
Create GitHub Release:
# Option A: Using Git CLI
git tag v1.0.0
git push origin v1.0.0
# Then create release from tag in GitHub UI
# Option B: Using GitHub CLI
gh release create v1.0.0 --title "Release 1.0.0" --generate-notesMonitor the workflow - Actions tab shows progress
Verify on Maven Central - available within ~10-15 minutes
v1.0.0 (with
v prefix)1.0.0 (without
v prefix, extracted automatically)pom.xml changes needed -
version is set from tag during buildio.github.rajendarreddyj namespaceGenerate a GPG key for signing artifacts:
# Generate a new GPG key
gpg --full-generate-keyWhen prompted, select: 1. Key type: 1
(RSA and RSA - default and recommended) 2. Key size:
4096 (stronger security, required for Maven Central) 3.
Expiration: 0 for no expiration, or
specify duration (e.g., 2y for 2 years) 4. Real
name: Your name (e.g., RajendarReddy Jagapathi)
5. Email: Your email (e.g.,
rajendarreddyj@gmail.com) 6. Comment:
Optional, can leave blank 7. Passphrase: Choose a
strong passphrase (save this for GPG_PASSPHRASE
secret)
# List keys to get the key ID
gpg --list-secret-keys --keyid-format=long
# Export the public key to a keyserver
gpg --keyserver keyserver.ubuntu.com --send-keys <KEY_ID>
# Export the private key (for CI/CD)
gpg --armor --export-secret-keys <KEY_ID> > private-key.ascConfigure these secrets in your GitHub repository (Settings → Secrets and variables → Actions):
| Secret Name | Description | Example |
|---|---|---|
OSSRH_USERNAME |
Sonatype portal token username | l3x7k9... |
OSSRH_TOKEN |
Sonatype portal token password | ghp_... |
GPG_PRIVATE_KEY |
ASCII-armored GPG private key | Contents of private-key.asc |
GPG_PASSPHRASE |
GPG key passphrase | Your GPG passphrase |
maven-centralThe simplest and recommended approach - just create a release:
v1.0.0 (from main
branch)Release 1.0.01.0.0 from tag
v1.0.0Using GitHub CLI:
gh release create v1.0.0 --title "Release 1.0.0" --generate-notesUsing Git + GitHub UI:
git tag v1.0.0
git push origin v1.0.0
# Then go to GitHub → Releases → create release from tagFor testing or manual releases:
# Set environment variables
export MAVEN_USERNAME="your-ossrh-username"
export MAVEN_PASSWORD="your-ossrh-token"
# Build and deploy
mvn clean deploy -Prelease
# Or deploy without tests (if already verified)
mvn deploy -Prelease -DskipTestsBefore publishing a release:
After creating the release: - [ ] Verify workflow completed successfully in Actions tab - [ ] Verify artifact on Maven Central (~10-15 minutes)
Follow Semantic Versioning:
X.0.0): Breaking API
changes0.X.0): New features,
backward compatible0.0.X): Bug fixes, backward
compatibleAfter successful publication:
gpg: signing failed: No secret key
Solution: Ensure GPG_PRIVATE_KEY
secret contains the full ASCII-armored key including headers.
401 Unauthorized
Solution: Regenerate Sonatype token and update
OSSRH_USERNAME and OSSRH_TOKEN secrets.
Invalid POM: Missing required fields
Solution: Ensure pom.xml has all
required elements: - name, description,
url - licenses - developers -
scm
Repository does not allow updating assets
Solution: You cannot republish the same version. Increment the version number.
After publishing, users can add the plugin to their project:
<build>
<plugins>
<plugin>
<groupId>io.github.rajendarreddyj</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
</plugins>
</build>Or use the plugin directly:
mvn io.github.rajendarreddyj:tomcat-maven-plugin:1.0.0:run