Skip to content

Commit

Permalink
Merge pull request #36 from kndpio/35-set-version-information-for-on-…
Browse files Browse the repository at this point in the history
…application-build

linked version to ldflags in GA
  • Loading branch information
evghen1 authored Feb 15, 2024
2 parents 2898776 + e99837b commit 2959ef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ jobs:
goos: linux
goarch: amd64
project_path: "./cmd/kndp"
binary_name: "kndp"
binary_name: "kndp"
ldflags: -X 'main.Version=${{ vars.GITHUB_REF_NAME }}'
6 changes: 4 additions & 2 deletions cmd/kndp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -62,7 +64,7 @@ type helpCmd struct{}
func main() {
c := cli{
Globals: Globals{
Version: VersionFlag("0.0.1"),
Version: VersionFlag(Version),
},
}

Expand All @@ -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,
Expand Down

0 comments on commit 2959ef2

Please sign in to comment.