diff --git a/.github/workflows/releases.yaml b/.github/workflows/releases.yaml index 5e21b94..bc3e3ea 100644 --- a/.github/workflows/releases.yaml +++ b/.github/workflows/releases.yaml @@ -25,4 +25,5 @@ jobs: goos: linux goarch: amd64 project_path: "./cmd/kndp" - binary_name: "kndp" \ No newline at end of file + binary_name: "kndp" + ldflags: -X 'main.Version=${{ vars.GITHUB_REF_NAME }}' \ No newline at end of file diff --git a/cmd/kndp/main.go b/cmd/kndp/main.go index 74dc5a1..47fe4ad 100644 --- a/cmd/kndp/main.go +++ b/cmd/kndp/main.go @@ -25,6 +25,8 @@ type Globals struct { type VersionFlag string +var Version = "development" + func (v VersionFlag) Decode(ctx *kong.DecodeContext) error { return nil } func (v VersionFlag) IsBool() bool { return true } func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error { @@ -62,7 +64,7 @@ type helpCmd struct{} func main() { c := cli{ Globals: Globals{ - Version: VersionFlag("0.0.1"), + Version: VersionFlag(Version), }, } @@ -73,7 +75,7 @@ func main() { return kong.DefaultHelpPrinter(options, ctx) }), kong.Vars{ - "version": "0.0.1", + "version": Version, }, kong.ConfigureHelp(kong.HelpOptions{ Tree: true,