From e55620ccba9a2ac123e5c8ecc8dea0057ea9d38e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 25 May 2020 10:52:37 -0600 Subject: [PATCH] add build versioning --- mplexer/cmd/telebit/telebit.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mplexer/cmd/telebit/telebit.go b/mplexer/cmd/telebit/telebit.go index 0018795..8ce82c1 100644 --- a/mplexer/cmd/telebit/telebit.go +++ b/mplexer/cmd/telebit/telebit.go @@ -1,3 +1,5 @@ +//go:generate go run -mod=vendor git.rootprojects.org/root/go-gitver + package main import ( @@ -19,6 +21,15 @@ import ( _ "github.com/joho/godotenv/autoload" ) +var ( + // GitRev refers to the abbreviated commit hash + GitRev = "0000000" + // GitVersion refers to the most recent tag, plus any commits made since then + GitVersion = "v0.0.0-pre0+0000000" + // GitTimestamp refers to the timestamp of the most recent commit + GitTimestamp = "0000-00-00T00:00:00+0000" +) + type Forward struct { scheme string pattern string @@ -45,6 +56,13 @@ func main() { locals := flag.String("locals", "", "a list of :") flag.Parse() + if len(os.Args) >= 2 { + if "version" == os.Args[1] { + fmt.Printf("telebit %s %s %s", GitVersion, GitRev, GitTimestamp) + os.Exit(0) + } + } + if "" != *acmeDirectory { if *acmeStaging { fmt.Fprintf(os.Stderr, "pick either acme-directory or acme-staging\n")