This guide covers how to publish KmpPrinter to GitHub Maven and Maven Central.
- Create an account at https://issues.sonatype.org (login with GitHub)
- Create a new Community Support ticket:
- Project: Community Support - Open Source Project Repository Hosting
- Summary:
New OSSRH project for io.github.ringga-dev - Group Id:
io.github.ringga-dev
- Login to https://central.sonatype.com/ with GitHub
- Verify your namespace
io.github.ringga-dev - Generate User Token: Profile β User Token β Generate
- Save the token values β use as
SONATYPE_USERNAMEandSONATYPE_PASSWORDsecrets
# Generate a GPG key (use ringga.dev@gmail.com as email)
gpg --full-generate-key
# List keys to get your KEY_ID
gpg --list-keys --keyid-format LONG
# Upload to keyserver
gpg --keyserver keyserver.ubuntu.com --send-keys <YOUR_KEY_ID>
# Export private key (for GitHub Actions)
gpg --armor --export-secret-keys <YOUR_KEY_ID>Add these secrets to your GitHub repository at: Settings β Secrets and variables β Actions β New repository secret
| Secret | Value |
|---|---|
SONATYPE_USERNAME |
Your Sonatype JIRA username |
SONATYPE_PASSWORD |
Your Sonatype JIRA password |
GPG_SIGNING_KEY |
Output of gpg --armor --export-secret-keys <KEY_ID> |
GPG_PASSWORD |
The passphrase you used for the GPG key |
Use the release script β it reads the version from gradle.properties, syncs docs, and creates the git tag:
# 1. Update version (single source of truth)
# Edit gradle.properties β change LIB_VERSION
# 2. Run release script
./scripts/release.sh
# 3. Push to trigger CI
git push origin master --tagsGitHub Actions then automates everything:
- β Tests & compile all platforms
- β Build Android AAR, iOS XCFramework, JVM Jar
- β
CI verifies tag matches
LIB_VERSION(fails if mismatch) - β
Deploy to GitHub Maven (
maven-repobranch) - β Deploy to Maven Central (Central Portal)
- β Create GitHub Release with artifacts
If you prefer to do it step by step:
-
Update
LIB_VERSIONingradle.properties(single source of truth):# Example: change this in gradle.properties LIB_VERSION=2.3.3 -
Sync documentation version references:
./gradlew syncDocumentationVersion
-
Commit and tag:
git add -A git commit -m "chore: release v2.3.1" git tag v2.3.1 git push origin master --tags
β οΈ Important: The git tag (e.g.,v2.3.1) must matchLIB_VERSIONingradle.properties. CI will verify this and fail if they don't match.
- Check Maven Central: https://repo1.maven.org/maven2/io/github/ringga-dev/
- It takes ~10-30 minutes for artifacts to appear after Sonatype close & release
- Library will then be available at:
No extra repository needed! Just
implementation("io.github.ringga-dev:kmp_printer:2.3.3")mavenCentral()in your build file.
# Publish to local Maven repo (validates build + signing)
export GPG_SIGNING_KEY="<key>"
export GPG_PASSWORD="<pass>"
./gradlew :printer:publishAllPublicationsToLocalRepoRepository
# Check output in:
# printer/build/repo/| Where | Coordinates | Repository Needed? |
|---|---|---|
| GitHub Maven | io.github.ringga-dev:kmp_printer:VERSION |
β Custom Maven URL |
| Maven Central | io.github.ringga-dev:kmp_printer:VERSION |
β Just mavenCentral() |
The publish.yml workflow:
- check β Runs tests and cross-compiles
- setup β Reads LIB_VERSION
- build-{platform} β Builds AAR, XCFramework, JAR
- deploy-github-maven β Pushes to
maven-repobranch + creates Sonatype bundle - deploy-maven-central β Publishes to Sonatype OSSRH staging
- create-release β Creates GitHub Release with artifacts