๐ Releasing KmpPrinter
This guide covers how to publish KmpPrinter to GitHub Maven and Maven Central.
๐ Prerequisites (One-Time Setup)
1. Sonatype Account (for 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
2. Central Portal (new Maven Central)
- 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
3. GPG Key (for Artifact Signing)
# 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>
3. GitHub Secrets
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 |
๐ Release Process
Automatic Release (Recommended)
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 --tags
GitHub 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-repo branch)
- โ
Deploy to Maven Central (Central Portal)
- โ
Create GitHub Release with artifacts
Manual Release
If you prefer to do it step by step:
-
Update
LIB_VERSIONingradle.properties(single source of truth):
bash # Example: change this in gradle.properties LIB_VERSION=2.3.3 -
Sync documentation version references:
bash ./gradlew syncDocumentationVersion -
Commit and tag:
bash 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.
After Release
- 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:
kotlin implementation("io.github.ringga-dev:kmp_printer:2.3.3")
No extra repository needed! JustmavenCentral()in your build file.
๐งช Testing a Release Locally
# 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/
๐ฆ Distribution Options
| 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() |
๐ง CI/CD Pipeline
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