Release Version Management#
The kpt repository uses independent versioning for each Go module and automates version injection into both the compiled binary and the Hugo-based documentation site.
Go Module Layout & Tag Conventions#
The repository contains several independent Go modules, each with its own go.mod and release lifecycle:
| Module | Path | Release Tag Pattern |
|---|---|---|
github.com/kptdev/kpt | go.mod | v[1-9].*.* (e.g. v1.2.3) |
github.com/kptdev/kpt/api | api/go.mod | api/v[0-9]+.[0-9]+.[0-9]+* (e.g. api/v0.0.1) |
github.com/kptdev/kpt/mdtogo | mdtogo/go.mod | — |
github.com/kptdev/kpt/healthcheck | healthcheck/go.mod | — |
github.com/kptdev/docs | documentation/go.mod | — |
The CLI root module (github.com/kptdev/kpt) and the API module (github.com/kptdev/kpt/api) are released independently . The api module was split into its own independent Go module in PR #4537, and its Go release workflow watches for api/v* tags . A formal VERSIONING.md (added in PR #4622) documents compatibility guarantees — notably that minor versions are not guaranteed backwards compatible.
Binary Version Injection (LDFLAGS)#
For local/development builds, KPT_VERSION is set to a timestamp string development-<timestamp> in make/info.mk. This is injected into the binary at compile time via LDFLAGS targeting github.com/kptdev/kpt/run.version . Note: binaries built via go install (not from the Makefile) will report unknown for kpt version .
For tagged releases, GoReleaser replaces the version with the git tag value using the same ldflags pattern: -X github.com/kptdev/kpt/run.version={{.Version}}. The GoReleaser config lives at release/tag/goreleaser.yaml and builds binaries for darwin/linux × amd64/arm64, plus Docker images tagged as ghcr.io/kptdev/kpt:{{ .Tag }} .
CI Release Workflows#
Two GitHub Actions workflows manage releases:
.github/workflows/release.yml— Triggered on tags matchingv[1-9].*.*. Runsmake all, then GoReleaser, and generates SLSA3 provenance for binaries..github/workflows/release-api.yml— Triggered on tags matchingapi/v[0-9]+.[0-9]+.[0-9]+*. Runsmake apiagainstapi/go.mod.
Hugo Documentation Version Injection#
Documentation at kpt.dev renders the current release version in multiple places (Docker pull commands, binary download links, etc.) using the Hugo shortcode {{< kpt_version >}}.
The shortcode documentation/layouts/shortcodes/kpt_version.html resolves the version in priority order:
- Environment variable
HUGO_KPT_VERSION— set at build time - Fallback:
kpt_versionsite param indocumentation/config.toml(currently"v1.0.0-beta.62.1")
The documentation/Makefile sets HUGO_KPT_VERSION dynamically using git describe --tags --abbrev=0 for both production-build and preview-build targets :
HUGO_KPT_VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || true) hugo --minify
This means documentation builds automatically pick up the latest git tag without requiring manual edits to config.toml. The fallback value in config.toml is used for local serve builds and acts as a default for PRs where no tag is present.
This versioning wiring was introduced in PR #4511.
Key Files#
| File | Purpose |
|---|---|
make/info.mk | KPT_VERSION + LDFLAGS for development builds |
release/tag/goreleaser.yaml | GoReleaser config: binaries, Docker images, changelog |
.github/workflows/release.yml | CLI release pipeline (tag v*) |
.github/workflows/release-api.yml | API module release pipeline (tag api/v*) |
documentation/layouts/shortcodes/kpt_version.html | Hugo shortcode: env var → site param fallback |
documentation/config.toml | Static fallback kpt_version param |
documentation/Makefile | Sets HUGO_KPT_VERSION from git describe at build time |
VERSIONING.md | Policy: SemVer strategy, compatibility, pinning guidance |