Skip to content

Commit

Permalink
Merge pull request #40 from imiric/fix/version-output
Browse files Browse the repository at this point in the history
Expand version output to include Go version and arch info
  • Loading branch information
gzuidhof authored Oct 4, 2023
2 parents f0e07f9 + 4bb202e commit 50c1ef0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions cmd/buildinfo.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package cmd

import (
"fmt"
"runtime"
)

// Field injected by goreleaser
var (
version = "<unknown>"
commitDate = "date unknown"
commit = ""
target = ""
)

func Version() string {
Expand All @@ -21,5 +25,10 @@ func Commit() string {
}

func Target() string {
return target
return runtime.GOOS
}

func FullVersion() string {
return fmt.Sprintf("%s %s/%s %s (%s) %s",
version, runtime.GOOS, runtime.GOARCH, runtime.Version(), commitDate, commit)
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Execute() {

rootCmd.PersistentFlags().
String("config", "tygo.yaml", "config file to load (default is tygo.yaml in the current folder)")
rootCmd.Version = Version() + " " + Target() + " (" + CommitDate() + ") " + Commit()
rootCmd.Version = FullVersion()
rootCmd.PersistentFlags().BoolP("debug", "D", false, "Debug mode (prints debug messages)")

rootCmd.AddCommand(&cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ builds:
goarch:
- amd64
ldflags:
- -s -w -X github.com/gzuidhof/tygo/cmd.version={{.Version}} -X github.com/gzuidhof/tygo/cmd.commit={{.Commit}} -X github.com/gzuidhof/tygo/cmd.commitDate={{.CommitDate}} -X github.com/gzuidhof/tygo/cmd.target={{.Env.GOOS}}
- -s -w -X github.com/gzuidhof/tygo/cmd.version={{.Version}} -X github.com/gzuidhof/tygo/cmd.commit={{.Commit}} -X github.com/gzuidhof/tygo/cmd.commitDate={{.CommitDate}}
archives:
- id: tygo
name_template: >-
Expand Down

0 comments on commit 50c1ef0

Please sign in to comment.