Publishing
Status: ⚪ Planned —
[signing],[repositories], and publishing metadata all parse, and thekargo-mavencrate has the module in place, butkargo publishandkargo loginare not implemented. This page describes the intended behavior. See Implementation Status.
Kargo publishes to any Maven repository: Maven Central, Google's, a corporate Nexus or Artifactory, or GitHub Packages.
kargo publish
What a published release needs
[package]
name = "my-lib"
group = "com.example" # required — the Maven group id
version = "1.0.0"
kotlin = "2.4.21"
description = "A useful library"
license = "Apache-2.0"
repository = "https://github.com/example/my-lib"
authors = ["Jane Doe <jane@example.com>"]
group, name, and version become the coordinate
com.example:my-lib:1.0.0. The metadata fields become POM elements — and Maven
Central rejects a POM missing a description, a license, a developer, or an SCM
URL, so filling them in is not optional if that is where you are publishing.
What gets uploaded
| Artifact | Contents |
|---|---|
my-lib-1.0.0.jar | Compiled classes |
my-lib-1.0.0.pom | Dependencies and metadata |
my-lib-1.0.0-sources.jar | Sources, for IDE navigation |
my-lib-1.0.0-javadoc.jar | KDoc-generated documentation |
*.asc | GPG signatures, when signing is configured |
*.md5, *.sha1, *.sha256 | Checksums |
Multiplatform projects publish one artifact per target plus a root module with Gradle Module Metadata, so Gradle consumers get the right platform artifact automatically.
Where it goes
[repositories]
releases = { url = "https://nexus.example.com/repository/maven-releases", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }
snapshots = { url = "https://nexus.example.com/repository/maven-snapshots", auth = "my-nexus" }
kargo publish --repository releases
A version ending in -SNAPSHOT publishes with a timestamp, and republishing the
same snapshot version is allowed. Release versions are immutable: a repository
that already has 1.0.0 rejects a second upload, which is a feature.
Authentication
Credentials come from .kargo.env or global
config — never from a committed manifest.
kargo login # store a token for a repository
kargo login --repository releases
# ~/.kargo/config.toml
[credentials.my-nexus]
username = "deploy"
token-cmd = "op read 'op://Dev/Nexus/token'"
token-cmd keeps the secret in your password manager rather than on disk.
kargo publish refuses to run if the manifest contains unresolved ${env:…}
placeholders, so a missing variable cannot be published as a literal string.
Signing
Maven Central requires GPG signatures.
[signing]
gpg-key = "${env:GPG_KEY_ID}"
gpg-password = "${env:GPG_PASSPHRASE}"
# .kargo.env
GPG_KEY_ID=ABCD1234
GPG_PASSPHRASE=…
Every uploaded artifact gets a detached .asc signature. Your public key must be
on a keyserver Central checks before the release validates.
A release in practice
kargo test # 1. green
kargo audit # 2. no known vulnerabilities
# 3. set the version in Kargo.toml
kargo build --release # 4. build what you will ship
kargo publish --dry-run # 5. see what would upload
kargo publish # 6. upload
git tag v1.0.0 && git push --tags # 7. tag the commit
--dry-run builds and signs everything, then stops before upload. Use it the
first time you publish to a new repository, where the failure mode is a
half-uploaded release.
Versioning
Semver, and version must parse as semver or the manifest is rejected.
| Change | Bump |
|---|---|
| Removed or changed a public signature | Major |
| Added public API, compatibly | Minor |
| Fixed something, no API change | Patch |
Kotlin-specific traps worth knowing: adding a parameter with a default value is
source-compatible but not binary-compatible; neither is adding a member to an
interface without a default implementation; and changing a data class's
constructor breaks its generated copy. All three are major bumps for a published
library.
GitHub Packages
[repositories]
github = { url = "https://maven.pkg.github.com/example/my-lib", username = "${env:GITHUB_ACTOR}", password = "${env:GITHUB_TOKEN}" }
- env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: kargo publish --repository github
Next
- Packaging — distributables rather than Maven artifacts
- Secrets and Environment — credential handling
- Continuous Integration — publishing from a tag