Skip to content

feat: extend --version with commit, date, dirty flag, and build profile - #228

Closed
justin13888 wants to merge 1 commit into
marcus:mainfrom
justin13888:feat-improved-version
Closed

justin13888 wants to merge 1 commit into
marcus:mainfrom
justin13888:feat-improved-version

Conversation

@justin13888

Copy link
Copy Markdown

Add Commit, Dirty, BuildDate, and BuildProfile ldflags variables so --version outputs granular build identification details. Falls back to debug.ReadBuildInfo() for dev builds without injected ldflags.

Update Makefile to inject all metadata for build/install/install-dev/ build-all targets, and .goreleaser.yml to pass ShortCommit, Date, and profile=release for release pipeline builds.

Add Commit, Dirty, BuildDate, and BuildProfile ldflags variables so
--version outputs granular build identification details. Falls back to
debug.ReadBuildInfo() for dev builds without injected ldflags.

Update Makefile to inject all metadata for build/install/install-dev/
build-all targets, and .goreleaser.yml to pass ShortCommit, Date, and
profile=release for release pipeline builds.
@justin13888

Copy link
Copy Markdown
Author

This resolves #227

@marcus

marcus commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Hey @justin13888! Starling here (AI assistant on the project). 👋

Nice — this is the standard Go pattern for build info, done right. A few observations:

  • ✅ Using -ldflags for injection is the idiomatic approach and keeps the binary lean
  • ✅ The debug.ReadBuildInfo() fallback for dev builds is a solid touch — no broken --version in local builds
  • ✅ Updating both Makefile and .goreleaser.yml so release and local builds are consistent
  • ✅ The dirty flag will be genuinely useful for bug reports ("are you on a clean build?")

The output format in the issue looks clean and readable. Flagging @marcus to review and merge — this one seems pretty ready. ✦

@marcus marcus mentioned this pull request Mar 3, 2026
@marcus

marcus commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Hi @justin13888, and apologies for the long silence here. You got a comment back in March saying this looked ready to merge, and then it sat. That is on me.

Here is where things landed. Since this PR opened, the managed dev install path in scripts/dev-install.sh started encoding branch, commit, and dirty state directly into the version string, so a local build now reports something like sidecar version devel+main.577c47fc, and make install-status records which sibling module revisions were compiled in. That covers most of what issue #227 was asking for, but through a different design than this PR: one composite version string rather than separate ldflags variables. The two approaches conflict, and reconciling them means reworking dev-install.sh as well, which is a different piece of work than what you signed up for.

So I am closing this rather than asking you to rebase into a moving target. I want to be clear that the PR was not the problem. It was clean, and it sat too long, and the ground shifted underneath it.

The part your PR solved that is still unsolved is release builds. Goreleaser still injects only the bare version, so a Homebrew binary cannot be traced back to a commit or a build date. Rather than leave that on the floor, I am pulling that piece of your work in directly, adapted to fit the current version scheme, with you credited on the commit. #227 stays open until it lands.

Thanks for the contribution, and sorry again for the wait.

@marcus marcus closed this Aug 27, 2026
marcus added a commit that referenced this pull request Aug 27, 2026
A released binary printed only `sidecar version v1.9.0`, so a bug report
from a Homebrew install could not be traced to a commit. Release builds now
carry ShortCommit and the build date from goreleaser, `make build`/`make
install` stamp commit and dirty state, and builds without ldflags fall back
to debug.ReadBuildInfo.

The first line stays exactly `sidecar version <v>`: dev-install.sh matches
it by prefix and verify-release-archives.sh compared the whole output, which
is now a first-line comparison. Detail goes on indented lines below.

The Makefile deliberately does not stamp main.Version. These are unmanaged
builds of possibly-unreleased code, and a `git describe` tag would make
internal/version read them as an up-to-date release and stop offering
updates.

Adapted from #228 by @justin13888, which predated the composite version
string that scripts/dev-install.sh now builds. Closes #227.

Co-Authored-By: Justin Chung <20733699+justin13888@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ut1zrG8kFmZQpPAkTYzCkd
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