Skip to content

Publish to Maven Central#64

Merged
notKamui merged 8 commits into
notKamui:mainfrom
theoholl:publish-to-maven-central
May 23, 2026
Merged

Publish to Maven Central#64
notKamui merged 8 commits into
notKamui:mainfrom
theoholl:publish-to-maven-central

Conversation

@theoholl
Copy link
Copy Markdown
Contributor

@theoholl theoholl commented May 19, 2026

Updates publishing to Maven Central as described on this Kotlin documentation page. It uses the vanniktech/gradle-maven-publish-plugin publishing Gradle plugin. Also, the Gradle wrapper and Kotlin have been upgraded and deprecated build targets removed.

To publish to Maven Central, you need to

  1. Create a user token on Maven Central
  2. Create and publish a GPG key
  3. Create a GitHub personal access token (classic) for publishing to GitHub packages
  4. Publish a new release on GitHub / run Gradle task manually

To publish using .github/workflows.publish.yaml, add the following repository secrets:

  • MAVEN_CENTRAL_USERNAME
  • MAVEN_CENTRAL_PASSWORD
  • SIGNING_KEY_ID (GPG signing key ID)
  • SIGNING_PASSWORD (password for GPG key)
  • GPG_KEY_CONTENTS (entire contents of your key.gpg file)
  • GH_PACKAGES_USER (your GitHub username)
  • GH_PACKAGES_TOKEN (your GitHub personal access tokens (classic) with package:write permission)

The Gradle task will upload the release to Maven Central, but you still have to manually publish them on the portal. Once you do that, you cannot remove/change the published components. If you want a fully automated release, you can change the Gradle task from publishToMavenCentral to publishAndReleaseToMavenCentral.

If you don't care for publishing to GitHub Packages, you can remove the publishing section on the bottom of build.gradle.kts and update the publish.yaml pipeline, gradle.properties.yaml and README.md accordingly.

@notKamui
Copy link
Copy Markdown
Owner

It's been a while since I've dealt with the JVM in any way, but the fact that the recommended way to publish an artifact is through a community plugin instead of a simple official easy way is insane to me.

In any case, thank you for your work !
Good idea with the github actions. At the time I didn't take the time to invest in learning how to use it, but now I can't do away without it.

@theoholl
Copy link
Copy Markdown
Contributor Author

It's been a while since I've dealt with the JVM in any way, but the fact that the recommended way to publish an artifact is through a community plugin instead of a simple official easy way is insane to me.

In any case, thank you for your work ! Good idea with the github actions. At the time I didn't take the time to invest in learning how to use it, but now I can't do away without it.

Agreed, especially since Gradle is such a widely adopted system ... apparently at least there is an official Maven one.

The PR is mostly complete now but I've kicked out the publishing to GitHub Packages which I'll add back in the next days. I've tried to summarize what I've learned in the PR description, is there anything unclear to you?

@notKamui
Copy link
Copy Markdown
Owner

notKamui commented May 21, 2026

is there anything unclear to you?

Not really ! I've quickly read through the docs, and the PR. I'm just gonna create a new signing key and sonatype user token and add that to the repo's env. :)

@theoholl theoholl marked this pull request as ready for review May 22, 2026 13:45
@notKamui
Copy link
Copy Markdown
Owner

Great work, thank you for your help and guidance. I'm gonna fix some things like emails and the likes before merging, but you can consider it as done !

@notKamui notKamui merged commit 642a1b0 into notKamui:main May 23, 2026
1 check passed
@theoholl theoholl deleted the publish-to-maven-central branch May 24, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants