Skip to content

Add version command #230

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add version command #230

wants to merge 2 commits into from

Conversation

adamancini
Copy link
Member

Summary

  • Adds version subcommand to display sbctl version and Go compiler version
  • Updates Makefile to set version during build time
  • Updates README with version command documentation

Test plan

  1. Build the binary with \go mod tidy
    go fmt ./pkg/... ./cli/... ./tests/...
    go vet -tags "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp" -installsuffix netgo ./pkg/... ./cli/... ./tests/...
    go build -o bin/sbctl -ldflags "-X github.com/replicatedhq/sbctl/cli.Version=v0.17.1-33-gadd33d0" sbctl.go
  2. Run \v0.17.1-33-gadd33d0
    go1.24.2 to verify it displays both the sbctl version and Go compiler version

@adamancini adamancini mentioned this pull request Apr 22, 2025
Copy link
Member

@banjoh banjoh left a comment

Choose a reason for hiding this comment

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

I'd prepend sbctl to the version string. Something like below

sbctl version v0.17.1-33-gadd33d0
go version go1.24.2

scottrigby

This comment was marked as outdated.

scottrigby

This comment was marked as outdated.

@scottrigby scottrigby dismissed their stale review April 22, 2025 15:57

Somehow I got back to this to review before I saw Evan's comment. I agree adding the Go version would also be helpful

@scottrigby
Copy link

Please ignore all the noise above. Wish I could hide my stale review reason. Anyway, moving along here…

I'd prepend sbctl to the version string. Something like below

sbctl version v0.17.1-33-gadd33d0
go version go1.24.2

@banjoh thinking about it slightly more… at risk of bikeshedding, I like the output as-is:

$ ./bin/sbctl version
v0.17.1-33-gadd33d0
go1.23.8

I think it's clear the first line is the command version, and go version already has go prepended.
Either would be fine, just thought I'd share my thoughts.

@adamancini
Copy link
Member Author

@banjoh @scottrigby I don't have any objections to either, for reference the replicated CLI looks like this:

 ✔  AdaM-GK2GXPC49X  ~/go/src/github.com/replicatedhq  replicated version
replicated version 0.101.1

@adamancini adamancini requested a review from banjoh April 23, 2025 18:26
@adamancini
Copy link
Member Author

@banjoh ready for re-review:

 ./bin/sbctl version           
sbctl version v0.17.1-33-gadd33d0
go version go1.24.2

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.

3 participants