Skip to content

✨ feat: build-stamped version for both binaries (VERSION-01) - #290

Merged
konih merged 1 commit into
mainfrom
feat/version-01-build-stamp
Aug 10, 2026
Merged

konih merged 1 commit into
mainfrom
feat/version-01-build-stamp

Conversation

@Xiilent

@Xiilent Xiilent commented Aug 9, 2026

Copy link
Copy Markdown

Neither binary had any build-stamped version: all four build sites (Taskfile.yml's build/build:cli tasks, Dockerfile, Dockerfile.pipeline) used plain -ldflags="-w -s", no -X, no internal/version package — so both shipped with no way to tell what commit or release they were built from.

Adds internal/version (Version/Commit/Date vars + String(), "dev"/"unknown" defaults for go build/run/test without -ldflags) and wires it into all four build sites: Taskfile.yml computes git describe/rev-parse/date locally; the two Dockerfiles take VERSION/COMMIT/DATE build-args (defaulted so a plain docker build still works) for the release pipeline to pass in. The manager gets a --version flag; kollect-pipeline gets cobra's built-in --version via Command.Version.

Left out: wiring real --build-arg values into the Makefile/release workflow, since both are being touched by the in-flight ADR-0708 hub-distribution PR (#284).

@Xiilent
Xiilent requested a review from konih as a code owner August 9, 2026 09:24
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@konih
konih force-pushed the feat/version-01-build-stamp branch from 1e1fd4f to f6260d8 Compare August 10, 2026 14:17

@konih konih left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW: APPROVE (external-contributor path — reviewed per /merge-open-prs Step 3)

The check that mattered: ARG scoping. A global ARG declared before FROM is not visible inside a build stage, which would have made the -X substitutions expand to empty strings and silently ship an unstamped binary — and CI would never have caught it, because the docker-build job passes no --build-arg and would produce the same dev/unknown either way. Verified both files declare VERSION/COMMIT/DATE after FROM ... AS builder (Dockerfile:8-10, Dockerfile.pipeline:10-12), so the args are in-stage and the RUN go build expands them correctly. The defaults also match internal/version's own Go defaults, so a plain docker build reports dev/unknown honestly rather than a plausible-looking fake version.

Verified end-to-end, not just by reading. Built both binaries from this branch with the Taskfile ldflags:

$ ./bin/kollect-pipeline --version
kollect-pipeline version v0.17.0-35-gf6260d8d6 (commit f6260d8d6, built 2026-08-10T14:19:13Z)
$ ./bin/manager --version
v0.17.0-35-gf6260d8d6 (commit f6260d8d6, built 2026-08-10T14:19:34Z)

This is worth stating explicitly because -X fails silently when the symbol path is wrong — it is a no-op, not a build error. Both binaries stamp for real.

Architecture — internal/version is added to the existing shared component, which is already in commonComponents. That is the minimal correct placement for a leaf package whose only import is fmt; it does not widen cmd/ → internal/ access generally.

Other

  • --version on the manager prints and os.Exit(0)s before any manager/webhook setup, so it works without a cluster or valid config.
  • build:cli correctly gains internal/version/** in its sources: list, so Taskfile's up-to-date check won't serve a stale binary after a version-package edit.
  • Defaults are asserted in TestBindStartupFlags_Defaults, so --version can't silently flip to true.

Follow-up (disclosed in the PR body, not a blocker) — the release workflow and Makefile don't yet pass --build-arg VERSION/COMMIT/DATE, so published container images will still report dev/unknown until that is wired. The deferral is reasonable given #284 (ADR-0708 hub distribution) is in flight over the same files, but this should land before the next release tag or the shipped images will carry a version string that is honest but useless. Worth a follow-up story.

CI green across all checks.

@konih
konih force-pushed the feat/version-01-build-stamp branch from f6260d8 to 441cd9d Compare August 10, 2026 14:25
Neither binary had any build-stamped version: all four build sites (Taskfile.yml's
build/build:cli tasks, Dockerfile, Dockerfile.pipeline) used plain -ldflags="-w -s",
no -X, no internal/version package — so both shipped with no way to tell what commit
or release they were built from.

Adds internal/version (Version/Commit/Date vars + String(), "dev"/"unknown" defaults
for go build/run/test without -ldflags) and wires it into all four build sites:
Taskfile.yml computes git describe/rev-parse/date locally; the two Dockerfiles take
VERSION/COMMIT/DATE build-args (defaulted so a plain `docker build` still works) for
the release pipeline to pass in. The manager gets a --version flag; kollect-pipeline
gets cobra's built-in --version via Command.Version.

Left out: wiring real --build-arg values into the Makefile/release workflow, since
both are being touched by the in-flight ADR-0708 hub-distribution PR (#284).
@konih
konih force-pushed the feat/version-01-build-stamp branch from 441cd9d to 7bc7b12 Compare August 10, 2026 14:34
@sonarqubecloud

Copy link
Copy Markdown

@konih
konih merged commit 1e906f5 into main Aug 10, 2026
36 checks passed
@konih
konih deleted the feat/version-01-build-stamp branch August 10, 2026 14:42
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