Cross-platform library template with base configuration to publish it in maven central.
If this is your first library, or you’ve only ever used Bintray to do this before, you will need to first register a Sonatype account.
There are many articles describing the registration process on the internet. The one from GetStream is exhaustive and up to date. You can start by following the first four steps, including "Generating a GPG key pair":
- Register a Jira account with Sonatype (you can use my issue as an example). ✅
- Verify your ownership of the group ID you want to use to publish your artifact by creating a GitHub repo. ✅
- Generate a GPG key pair for signing your artifacts. ✅
- Publish your public key. ✅
- Export your private key. ✅
When the Maven repository and signing keys for your library are prepared, we are ready to move forward and set up our build to upload the library artifacts to a staging repository and then release them!
You can publish a multiplatform library to a local Maven repository with the maven-publish Gradle plugin. Specify the group, version, and the repositories where the library should be published. The plugin creates publications automatically.
Official documentation: https://kotlinlang.org/docs/multiplatform-publish-lib.html
Create this variable on local.properties file:
signing.keyId={your key id}
signing.password={your key password}
signing.key={your key on base64}
ossrhUsername={oss username}
ossrhPassword={oss password}
Configure this variable on actions secrets file:
KEY_ID:
GPG_PRIVATE_KEY:
GPG_PRIVATE_PASSWORD:
SONATYPE_USERNAME
SONATYPE_PASSWORD:
- Publishing multiplatform libraries | Kotlin
- Publish a Kotlin/Multiplatform library on Maven Central
- Setting up a KMP shared library
- How to build and publish a Kotlin Multiplatform library Series' Articles
- Kotlin Multiplatform by Tutorials, Chapter 14: Creating Your KMP Library
- GitHub - KaterinaPetrova/mpp-sample-lib: Sample Kotlin Multiplatform library (jvm + ios + js)
- Publishing Android libraries to MavenCentral in 2021