This project is set up to publish to Maven Central via GitHub Actions. This document explains how to set up the necessary secrets and how to trigger a new release.
To publish to Maven Central, you need to set up the following secrets in your GitHub repository:
- Go to your repository on GitHub
- Click on "Settings" > "Secrets and variables" > "Actions"
- Add the following secrets:
| Secret Name | Description |
|---|---|
OSSRH_USERNAME |
Your Sonatype OSSRH username |
OSSRH_PASSWORD |
Your Sonatype OSSRH password |
SIGNING_KEY |
Your GPG private key in ASCII-armored format |
SIGNING_PASSWORD |
The passphrase for your GPG key |
If you already have a GPG key, you can export it in ASCII-armored format with:
gpg --export-secret-keys --armor YOUR_KEY_IDIf you don't have a GPG key yet, you can create one with:
gpg --gen-keyFollow the prompts to create your key, then export it as shown above.
The publishing workflow is triggered automatically when you create a new release on GitHub:
- Go to your repository on GitHub
- Click on "Releases" > "Create a new release"
- Enter a tag version (e.g.,
v1.0.0) - Enter a release title and description
- Click "Publish release"
The GitHub Actions workflow will automatically build, test, and publish the library to Maven Central.
You can also trigger the publishing workflow manually:
- Go to your repository on GitHub
- Click on "Actions" > "Publish to Maven Central"
- Click "Run workflow" > "Run workflow"
For testing purposes, you can also publish locally:
- Add your Sonatype credentials and GPG key information to your
~/.gradle/gradle.propertiesfile:
ossrhUsername=your-username
ossrhPassword=your-password
signingKey=your-gpg-key
signingPassword=your-gpg-passphrase- Run the publish task:
./gradlew publishAfter publishing, you can verify that your artifact is available on Maven Central by searching for it at:
https://search.maven.org/search?q=g:com.github.asm0dey%20AND%20a:staks
Note that it may take some time for the artifact to appear on Maven Central after publishing.