Get version from built metadata
All checks were successful
Build and Publish / release (push) Successful in 1m5s
All checks were successful
Build and Publish / release (push) Successful in 1m5s
This commit is contained in:
parent
870760443e
commit
f14bc47c7b
10
cmd/root.go
10
cmd/root.go
@ -6,6 +6,7 @@ import (
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
@ -83,7 +84,7 @@ func init() {
|
||||
rootCmd.AddCommand(project.ProjectCmd)
|
||||
|
||||
// Version
|
||||
rootCmd.Version = Version
|
||||
rootCmd.Version = getVersion()
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
@ -172,3 +173,10 @@ func checkConfigPerms(file string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
|
||||
return info.Main.Version
|
||||
}
|
||||
return Version
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user