Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Publishing

Status: ⚪ Planned — [signing], [repositories], and publishing metadata all parse, and the kargo-maven crate has the module in place, but kargo publish and kargo login are 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

ArtifactContents
my-lib-1.0.0.jarCompiled classes
my-lib-1.0.0.pomDependencies and metadata
my-lib-1.0.0-sources.jarSources, for IDE navigation
my-lib-1.0.0-javadoc.jarKDoc-generated documentation
*.ascGPG signatures, when signing is configured
*.md5, *.sha1, *.sha256Checksums

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.

ChangeBump
Removed or changed a public signatureMajor
Added public API, compatiblyMinor
Fixed something, no API changePatch

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