Kmplate-lib is a template to easily create a new Kotlin Multiplatform library with Maven Central publishing configuration.
- For Github Actions to post messages on Slack, you must create a new webhook URL by using the Incoming Webhook app.
- Create a new Github Actions secret with name
SLACK_WEBHOOK_URL
, and copy paste the webhook created in the previous step as
value of this secret.
We will configure 2 Slack bots to post message on Slack: one bot to check for outdated dependencies, and one bot for the build status.
To configure these 2 Slack bots, we need to create 3 Github Actions variables:
SLACK_GITHUB_ACTIONS_CHANNEL_NAME
: the name of the Slack channel where Github Actions will post messages (ie.myproject_build_status
).SLACK_GITHUB_ACTIONS_DEPENDENCY_UPDATES_ICON_URL
: the icon URL to be used as a profile picture for the "Dependency Updates" Slack bot.SLACK_GITHUB_ACTIONS_ICON_URL
: the icon URL to be used as a profile picture for the "Github Actions CI" Slack bot.
Publishing the library is done via Github Actions, from the workflow .github/workflows/publish.yml
, and will automatically publish a new version of the library to Maven Central, for every new
release created on Github.
- First, you need to create an account on Sonatype. Follow this guide: https://central.sonatype.org/publish/publish-guide/. You should end up with a username, a password and a staging
profile ID. - Once you have your account, you need to request the creation of your groupId (ie. 'com.mycompany.myname'). Create an issue on their Jira. Example: https://issues.sonatype.org/browse/OSSRH-97913.
- Then, create your secret key by following this guide: https://central.sonatype.org/publish/requirements/gpg/. You should end up with a secret key, a secret key ID and a **secret key password
**.
To configure the publishing, we need to create 6 Github Actions secrets:
OSSRH_GPG_SECRET_KEY
: The value of the secret key created.OSSRH_GPG_SECRET_KEY_ID
: The ID of the secret key created (the last 16 digits).OSSRH_GPG_SECRET_KEY_PASSWORD
: The password of the secret key created.OSSRH_PASSWORD
: Your Sonatype account password.OSSRH_STAGING_PROFILE_ID
: Your Sonatype staging profile ID.OSSRH_USERNAME
: Your Sonatype account username.
- Open
buildSrc/src/main/kotlin/ProjectConfiguration.kt
and rename the following things:- Line 11:
MyProject
object name with your own project name, - Line 12:
com.tweener.changehere
package name with your own package name. - Line 19: All the properties within the
object Maven
block with your own Maven Central publishing configuration.
- Line 11:
- Rename module
changehere
with the name of your library. This is the name that will be shown when published to Maven Central. - Open
settings.gradle.kts
and replaceMyProjectName
on line 17 with your own project name. - Open
changehere/build.gradle.kts
(oryourlibraryname/build.gradle.kts
if you renamed the module on step 2) and rename the following things:- Line 65:
changehere
with your own iOS framework name. - Line 74:
changehere
with your own JS file name for Wasm target. - Line 83:
changehere
with your own JS file name for JS target.
- Line 65:
- Rename packages name (
import
andpackage
) in all existing files:- Click on
Edit
>Find
>Replace in files
, - In the first input field, type
com.tweener.changehere
, - In the second input field, type your own package name,
- Click on
Replace all
button.
- Click on
- Replace
com/tweener/changehere
with your own directory path in the following directories:changehere/src/commonMain/kotlin/com/tweener/changehere
changehere/src/androidMain/kotlin/com/tweener/changehere
changehere/src/iosMain/kotlin/com/tweener/changehere
- Open
.github/workflows/buildRelease.yml
and replaceKmplate-lib
on line 1 with your own library name. - Open
.github/workflows/notify.yml
and replaceKmplate-lib
on lines 21 and 33 with your own library name.