-
Notifications
You must be signed in to change notification settings - Fork 18
chore: wire CLI version via ldflags at build time #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: wire CLI version via ldflags at build time #199
Conversation
Added ldflags configuration to GoReleaser and Makefile to inject the actual CLI version, commit hash, and build date at compile time. This ensures: - GoReleaser builds embed the release version from git tags - Local builds via `make build` use git describe for versioning - The version command displays accurate version info instead of "dev" Closes open-feature#192 Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Summary of ChangesHello @kriscoleman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the build process by integrating dynamic versioning information into the CLI binary. By leveraging Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a solid improvement by embedding version information into the CLI binary at build time using ldflags. The changes in both .goreleaser.yaml and the Makefile correctly implement this for both release and local builds. My review includes a couple of minor suggestions to improve consistency between the two build methods and to make the local build process more robust against custom variable values.
| ldflags: | ||
| - -s -w | ||
| - -X main.version={{ .Version }} | ||
| - -X main.commit={{ .FullCommit }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") | ||
| COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") | ||
| DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
| LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values for the -X flags are not quoted. If any of the variables (VERSION, COMMIT, DATE) are overridden with a value containing spaces, the build command will fail. To make the build more robust, you should quote the values being injected.
For example, if you run make build VERSION="my version", the current LDFLAGS would be -s -w -X main.version=my version ..., which would be parsed incorrectly by the linker. Quoting the values prevents this.
LDFLAGS := -s -w -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
|
|
|


This PR
Added ldflags configuration to GoReleaser and Makefile to inject the actual CLI version, commit hash, and build date at compile time.
This ensures:
make builduse git describe for versioningRelated Issues
Closes #192
How to test
To see the behavior when you built locally prior to this change, pull

mainand runmake installthen runopenfeatureand notice:To see the behavior after this change, pull this branch, run

make installand then runopenfeatureand notice more meaninful meta: