diff --git a/internal/metadata/version.go b/internal/metadata/version.go index ecac17b..5c5818f 100644 --- a/internal/metadata/version.go +++ b/internal/metadata/version.go @@ -1,7 +1,20 @@ package metadata -import "strings" +import ( + "os/exec" + "strings" +) -// This will be overwritten by goreleaser on build -var GoTomatoVersion = "devel" // The GoTomato version -var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version +var ( + GoTomatoVersion = "" // The GoTomato version + ProtocolVersion = "" // The protocol version +) + +func init() { + if GoTomatoVersion == "" { + output, _ := exec.Command("git", "describe", "--tags").Output() + trimmed_output := strings.TrimSpace(string(output)) // strip newlines + GoTomatoVersion = strings.TrimPrefix(trimmed_output, "v") // strip leading "v" + } + ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version +}