buildinfo

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package buildinfo exposes the forge binary's version metadata to packages that cannot depend on internal/cli (to avoid import cycles). The cmd/forge entrypoint and internal/cli are responsible for seeding this data at startup via Set; anything that wants to stamp the forge version into generated artifacts should read it from here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearPkgModuleVersion

func ClearPkgModuleVersion()

ClearPkgModuleVersion removes any override set by SetPkgModuleVersion, restoring the real build-info read.

func GitCommit

func GitCommit() string

GitCommit returns the git commit SHA recorded via Set. Falls back to the VCS revision from runtime build info when available.

func InstallableVersion

func InstallableVersion() string

InstallableVersion returns the forge binary's version ONLY when it is a ref that `go install ...@<ref>` can actually resolve from a module proxy — a release tag or a clean Go pseudo-version. For anything else (the "dev" sentinel, "(devel)", an empty value, or a `+dirty` pseudo-version from a dirty-tree build) it returns "" so callers fall back to pinning by git SHA instead.

This is the boundary that keeps `+dirty` out of generated CI: callers stamp this (not raw Version()) into the `go install` step, and the empty return routes the CI template's three-branch policy onto the SHA branch. See internal/templates/ci/github/ci.yml.tmpl.

func PkgModuleVersion

func PkgModuleVersion() string

PkgModuleVersion returns the version of github.com/reliant-labs/forge/pkg that THIS forge binary was actually compiled against, read from the binary's own build info (runtime/debug). Unlike PkgVersion (a release ldflags stamp), this is populated for ordinary `go install .../cmd/forge@<ref>` builds — the binary records a real, proxy-resolvable pseudo-version (e.g. v0.0.0-20260624040937-ce5dfbd929ed) that is already in the build's module cache. Scaffolded projects can pin it and let `go mod tidy` resolve forge/pkg offline, instead of the unresolvable `v0.0.0` the templates hard-coded when no version was known.

Returns "" when the version isn't a canonical require version — most importantly for a workspace build (local `go build` under go.work, where forge/pkg is replaced by the in-tree ./pkg and the dep shows as "(devel)"), in which case the dev sibling/vendoring flow applies instead. Robust to `forge_version: dev` binaries (the daemon): the "dev" label is the forge binary's own version, orthogonal to the forge/pkg dep version recorded here.

func PkgVersion

func PkgVersion() string

PkgVersion returns the published forge/pkg module version this binary was released against, or "" when none is known (dev builds, or a malformed stamp). A non-empty return is always a canonical semver version (vX.Y.Z[-pre]) safe to write into a go.mod require directive.

func Set

func Set(v, _, commit string)

Set records the forge binary's version metadata. It is intended to be called exactly once, from the main entrypoint. The date argument is accepted for call-site compatibility but is not currently retained.

func SetPkgModuleVersion

func SetPkgModuleVersion(v string)

SetPkgModuleVersion overrides the value PkgModuleVersion returns, bypassing the ambient binary build info. Test-only seam: build info is baked at compile time and depends on GOWORK, so scaffolder tests pin it here to stay deterministic. Pass "" to force the "no build-info version" path. Pair with ClearPkgModuleVersion in a t.Cleanup.

func SetPkgVersion

func SetPkgVersion(v string)

SetPkgVersion records the published forge/pkg module version this binary scaffolds against. Called from the main entrypoint when the release build stamped one via ldflags. Safe to call with "" (dev).

func Version

func Version() string

Version returns the forge binary's version. When the binary was produced by `go install ...@<ref>`, Set will not have been called with a real value, so we fall back to reading the module version from runtime build info.

Returns "dev" if neither source is available.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL