Skip to content
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

Add version support #210

Merged
merged 13 commits into from May 13, 2024
Merged

Add version support #210

merged 13 commits into from May 13, 2024

Conversation

egibs
Copy link
Collaborator

@egibs egibs commented May 10, 2024

Closes: #209

This PR adds support for a --version flag that will either use the newly-added VERSION file or check for the main.version build key.

Testing:

❯ go run . --version
bincapz 0.11.0
❯ go build -ldflags "-X main.version=$(cat VERSION)" && ./bincapz --version
bincapz 0.11.0

We aren't publishing binaries yet but this should work the same if we use the VERSION file as the source of truth; however, this file will need to be updated prior to any new releases being cut.

If there's a better way to handle this I'm all ears!

@egibs egibs requested a review from tstromberg May 10, 2024 14:20
egibs added 3 commits May 10, 2024 09:22
Signed-off-by: Evan Gibler <keybase@egibs.xyz>
Copy link
Collaborator

@tstromberg tstromberg left a comment

Choose a reason for hiding this comment

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

I like this feature, but would prefer if it could be done in such a way that it still works if you run:

go install . && cd /tmp && bincapz --version

What do you think about moving the version string out of the VERSION file and into a const - for instance version.ID?

egibs added 2 commits May 13, 2024 14:41
Signed-off-by: Evan Gibler <keybase@egibs.xyz>
VERSION Outdated
@@ -0,0 +1 @@
0.11.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can get rid of this now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed in 5be38e1 (#210).

bincapz.go Outdated
@@ -50,6 +51,8 @@ func main() {
statsFlag := flag.Bool("stats", false, "Show statistics about the scan")
thirdPartyFlag := flag.Bool("third-party", true, "Include third-party rules, which may have licensing restrictions")
verboseFlag := flag.Bool("verbose", false, "Emit verbose logging messages to stderr")
versionFlag := flag.Bool("version", false, "show version information")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalize "Show" for consistency with your more recent flag changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 9b582f9 (#210).

@tstromberg tstromberg merged commit ed485ed into chainguard-dev:main May 13, 2024
0 of 8 checks passed
@egibs egibs mentioned this pull request May 13, 2024
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.

Add a version command
2 participants