-
Notifications
You must be signed in to change notification settings - Fork 1
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
Kusk CLI version
- Partially closes kubeshop/kusk-gateway#415
#37
Conversation
References or inspired by ------------------------- * <https://github.com/cli/cli/blob/trunk/pkg/cmd/version/version.go> * <https://github.com/cli/cli/blob/trunk/internal/build/build.go> * <https://github.com/cli/cli/blob/trunk/pkg/cmd/version/version_test.go> * <https://github.com/cli/cli/blob/trunk/pkg/cmd/root/root.go#L75> * <https://github.com/cli/cli/blob/trunk/Makefile> * <https://github.com/cli/cli/blob/trunk/script/build.go> (search for `ldflags`)
Makefile
- Partially closes kubeshop/kusk-gateway#418:version
- Partially closes kubeshop/kusk-gateway#418
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.
I recommend we add version at build time just like I did in kusk-gayeway repo.
If we pass it as a LDFLAG when building we can ensure it won't be changed.
Correct me if I'm wrong?
Version information such as tag, revision and build date and time is built at _build_ time without having to resort to using `GO_LDFLAGS` or `-ldflags`, see: `internal/build/build.go`.
I took another approach which is to call |
Define a `version` command that uses value of `github.com/kubeshop/kusk-gateway/pkg/build` populated by `ldflags`: * `github.com/kubeshop/kusk-gateway`: Get latest version that includes `github.com/kubeshop/kusk-gateway/pkg/build` package. * `github.com/kubeshop/kusk-gateway/pkg/build`: `Version` variable will contain the latest tag when built. * `TELEMETRY_TOKEN`: Remove references to `ldflags`/build-arg that is not used. * `.github/workflows/go.yml`: Remove `test-GoReleaser-build` as we can just run it locally using `make build-goreleaser`. * `.goreleaser.yml`: Populate `KuskGAMeasurementID` based on secret/env. * `.goreleaser.yml`: Populate `KuskGAApiSecret` based on secret/env. Example run log --------------- ```sh $ make build Makefile:62: warning: undefined variable 'GA_ID' Makefile:62: warning: undefined variable 'GA_SECRET' go build -v -o ./kusk -ldflags="-X 'github.com/kubeshop/kusk-gateway/pkg/build.Version=v1.0.4-5-ga63345e' -X 'github.com/kubeshop/kusk-gateway/pkg/analytics.KuskGAMeasurementID=' -X 'github.com/kubeshop/kusk-gateway/pkg/analytics.KuskGAApiSecret='" ./main.go $ ./kusk version kusk version 1.0.4-5-ga63345e https://github.com/kubeshop/kusk/releases/latest $ ./kusk --version kusk version 1.0.4-5-ga63345e https://github.com/kubeshop/kusk/releases/latest $ ./kusk -v kusk version 1.0.4-5-ga63345e https://github.com/kubeshop/kusk/releases/latest ```
version
- Partially closes kubeshop/kusk-gateway#418version
- Partially closes kubeshop/kusk-gateway#415
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.
while at it could you just change go.mod to go 1.18
This is quite risky. Wouldn't it require anyone doing a |
I'd ditch go install as an install option |
I can do it as a separate PR ... ? What do you think? |
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.
LGTM!
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.
Ship it!
…usk-gateway#415 > agreed. Just check if it contains the version Just check the buffer contains the `version` in `Test_NewVersionCommand`.
go ahead and merge it |
…usk-gateway#415 `.goreleaser.yml`: Strip binary of debug information (`LD_FLAGS += -w -s`) etc. - reduces the size of final download.
Tested with: ./kusk version; ./kusk --version; ./kusk -v
kusk version 1.0.5-rc1
https://github.com/kubeshop/kusk/releases/tag/v1.0.5-rc1
kusk version 1.0.5-rc1
https://github.com/kubeshop/kusk/releases/tag/v1.0.5-rc1
kusk version 1.0.5-rc1
https://github.com/kubeshop/kusk/releases/tag/v1.0.5-rc1 Which seems right to me. |
Kusk CLI
version
- Partially closes kubeshop/kusk-gateway#415Define a
version
command that uses value ofgit.luolix.top/kubeshop/kusk-gateway/pkg/build
populated byldflags
:github.com/kubeshop/kusk-gateway
: Get latest version that includesgit.luolix.top/kubeshop/kusk-gateway/pkg/build
package.github.com/kubeshop/kusk-gateway/pkg/build
:Version
variable will contain the latest tag when built.TELEMETRY_TOKEN
: Remove references toldflags
/build-arg that is not used..github/workflows/go.yml
: Removetest-GoReleaser-build
as we can just run it locally usingmake build-goreleaser
..goreleaser.yml
: PopulateKuskGAMeasurementID
based on secret/env..goreleaser.yml
: PopulateKuskGAApiSecret
based on secret/env.Example run log
This PR...
Changes
Fixes
Checklist