This guide explains how to publish the BosBase Kotlin SDK to Maven Central (Sonatype Central Portal).
-
Sonatype Central Portal Account
- Sign up at https://central.sonatype.com
- Register a namespace (groupId) -
com.bosbase(requires domain ownership or GitHub namespace)
-
PGP Signing Key
- Generate a PGP key pair for signing artifacts using GPG
- Upload the public key to a keyserver (e.g., keyserver.ubuntu.com)
-
Environment Variables / GitHub Secrets
MAVEN_CENTRAL_USER- Your Sonatype Central Portal usernameMAVEN_CENTRAL_TOKEN- Your Sonatype Central Portal tokenSIGNING_KEY_ID- Your PGP key ID (last 8 characters of the key fingerprint)SIGNING_KEY- Your PGP private key (ASCII-armored, including BEGIN/END lines)SIGNING_PASSWORD- Passphrase for your PGP key
If you don't have a PGP key, you can generate one using GPG:
gpg --full-generate-keyWhen prompted:
- Choose
(1) RSA and RSA(default) - Key size:
4096bits - Expiration: Choose an expiration date (or
0for no expiration) - Enter your name and email
- Set a passphrase (you'll need this for signing)
After generation, get your key ID:
gpg --list-secret-keys --keyid-format LONGLook for a line like:
sec rsa4096/ABCD1234EFGH5678 2025-01-01 [SC]
The key ID is ABCD1234EFGH5678 (the part after rsa4096/). You'll need the last 8 characters for SIGNING_KEY_ID.
Export your private key (for use in CI/CD):
gpg --armor --export-secret-keys YOUR_KEY_ID > private-key.ascImportant: Keep private-key.asc secure and never commit it to version control!
Upload your public key to a keyserver:
gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_IDOr use another keyserver:
gpg --keyserver hkp://keyserver.ubuntu.com --send-keys YOUR_KEY_ID
gpg --keyserver hkp://pgp.mit.edu --send-keys YOUR_KEY_IDTest publishing to your local Maven repository:
cd kotlin-sdk
./gradlew publishToMavenLocalThis will publish to ~/.m2/repository/com/bosbase/bosbase-kotlin-sdk/.
-
Update the version in
build.gradle.kts:version = "0.1.1" // Update to your new version
-
Set environment variables:
export MAVEN_CENTRAL_USER="your-username" export MAVEN_CENTRAL_TOKEN="your-token" export SIGNING_KEY_ID="YOUR_KEY_ID" export SIGNING_KEY="$(cat private-key.asc)" export SIGNING_PASSWORD="your-passphrase"
-
Publish:
cd kotlin-sdk ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepositoryOr for manual release (publish first, then release via portal):
./gradlew publishToSonatype # Then go to https://central.sonatype.com → Deployments → Release
If you prefer the Central Portal Drop experience instead of pushing with Gradle:
- Build the bundle locally (this writes the Maven repository layout with the
.pomfile):./gradlew clean createSonatypeDropBundle
- Upload the generated
build/distributions/bosbase-kotlin-sdk-sonatype-bundle.zipfile on https://central.sonatype.com → Publish → Drop.
The task packages the jar, sources, Javadoc, and generated POM in the structure that Sonatype expects, so you won't see the Bundle has content that does NOT have a .pom file validation error.
The repository includes a GitHub Actions workflow (.github/workflows/publish-kotlin-sdk.yml) that automatically publishes when you:
-
Push a tag:
git tag kotlin-sdk/v0.1.1 git push origin kotlin-sdk/v0.1.1
-
Or trigger manually via GitHub Actions UI with a version number
Required GitHub Secrets:
MAVEN_CENTRAL_USERMAVEN_CENTRAL_TOKENSIGNING_KEY_IDSIGNING_KEY(full private key, including BEGIN/END lines)SIGNING_PASSWORD
- Check staging repository at https://central.sonatype.com → Deployments
- Release the staging repository (if not auto-released)
- Wait for sync - Your library will appear on:
- https://central.sonatype.com (within minutes)
- https://mvnrepository.com (within hours/days)
Once published, users can add the dependency:
dependencies {
implementation("com.bosbase:bosbase-kotlin-sdk:0.1.1")
}- Ensure
SIGNING_KEYincludes the full ASCII-armored key with BEGIN/END lines - Verify the key ID matches the last 8 characters of your key fingerprint
- Check that the passphrase is correct
- Verify credentials are correct in Sonatype Central Portal
- Check that your namespace (groupId) is registered and verified
- Ensure PGP public key is uploaded to a keyserver
- If you are uploading through the Central Portal Drop UI, always upload the bundle created by
./gradlew createSonatypeDropBundle. Uploading a raw JAR file will fail withBundle has content that does NOT have a .pom file.
- If auto-release fails, manually release via https://central.sonatype.com
- Check staging repository for validation errors