Skip to content

Stamp main.Version into release binaries via -ldflags#59

Merged
ianhodge merged 1 commit intomainfrom
metrics/release-version-ldflags
Apr 29, 2026
Merged

Stamp main.Version into release binaries via -ldflags#59
ianhodge merged 1 commit intomainfrom
metrics/release-version-ldflags

Conversation

@ianhodge
Copy link
Copy Markdown
Member

Adds a shared build-arg/workflow-input plumbed through the existing
release pipeline so oz_worker_info{version=...} reports the
published release tag (or commit SHA, for ad-hoc builds) instead of
the source default of "dev":

  • build_release.yml: new optional version workflow input. The build
    matrix step now passes -ldflags="-X main.Version=${VERSION}" with
    precedence version input > docker_tag input > github.sha. The
    same value is forwarded to the Docker build via --build-arg VERSION=... so the binary baked into the image carries the same
    version string as the standalone release archives.
  • create_release.yml: forwards the auto-generated release tag as both
    docker_tag and version, so a release whose tag is
    v2026-04-29-16-30-00 exposes that tag at
    oz_worker_info{version="v2026-04-29-16-30-00"} and ships in a
    Docker image tagged the same way.
  • Dockerfile: declares ARG VERSION=dev and threads it into the
    go build invocation. Local docker build without --build-arg
    still produces a "dev" binary, matching the source default.

Verified locally: go build -ldflags="-X main.Version=test-1.2.3" .
embeds the value in the binary; running --help works and strings
confirms the version string is present.

Co-Authored-By: Oz oz-agent@warp.dev

Copy link
Copy Markdown
Member Author

ianhodge commented Apr 29, 2026

@ianhodge ianhodge requested a review from bnavetta April 29, 2026 17:02
@ianhodge ianhodge marked this pull request as ready for review April 29, 2026 17:02
Base automatically changed from metrics/otel-autoexport to main April 29, 2026 17:06
Adds a shared build-arg/workflow-input plumbed through the existing
release pipeline so `oz_worker_info{version=...}` reports the
published release tag (or commit SHA, for ad-hoc builds) instead of
the source default of "dev":

- build_release.yml: new optional `version` workflow input. The build
  matrix step now passes `-ldflags="-X main.Version=${VERSION}"` with
  precedence `version` input > `docker_tag` input > `github.sha`. The
  same value is forwarded to the Docker build via `--build-arg
  VERSION=...` so the binary baked into the image carries the same
  version string as the standalone release archives.
- create_release.yml: forwards the auto-generated release tag as both
  `docker_tag` and `version`, so a release whose tag is
  `v2026-04-29-16-30-00` exposes that tag at
  `oz_worker_info{version="v2026-04-29-16-30-00"}` and ships in a
  Docker image tagged the same way.
- Dockerfile: declares `ARG VERSION=dev` and threads it into the
  `go build` invocation. Local `docker build` without `--build-arg`
  still produces a "dev" binary, matching the source default.

Verified locally: `go build -ldflags="-X main.Version=test-1.2.3" .`
embeds the value in the binary; running `--help` works and `strings`
confirms the version string is present.

Co-Authored-By: Oz <oz-agent@warp.dev>
@ianhodge ianhodge force-pushed the metrics/release-version-ldflags branch from 6d0954d to ccda767 Compare April 29, 2026 17:11
@ianhodge ianhodge merged commit 12dc5df into main Apr 29, 2026
9 checks passed
@ianhodge ianhodge deleted the metrics/release-version-ldflags branch April 29, 2026 17:55
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