diff --git a/Makefile b/Makefile index 45de93c..288fb5c 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,12 @@ GO := go PKG_BASE := $(shell head -n 1 go.mod | awk '{print $$2}') BUILD_TIME := $(shell date -u '+%Y%m%d-%I%M%S') -VERSION := $(shell cat VERSION)+$(shell git rev-parse --short HEAD) +VERSION := $(shell cat VERSION) +GIT_COMMIT := $(shell git rev-parse HEAD) LDFLAGS += -X $(PKG_BASE)/cmd.BuildTime=$(BUILD_TIME) LDFLAGS += -X $(PKG_BASE)/cmd.Version=$(VERSION) +LDFLAGS += -X $(PKG_BASE)/cmd.GitCommit=$(GIT_COMMIT) LDFLAGS += -X $(PKG_BASE)/cmd.SentryDSN=$(shell cat dsn.txt) LDFLAGS += -s -w diff --git a/cmd/common.go b/cmd/common.go index dada415..0560068 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -39,20 +39,26 @@ var App = &cli.App{ var ( BuildTime string Version string + GitCommit string SentryDSN string ) func init() { if BuildTime == "" { - BuildTime = "2022-09-06-01-00-00" + // First Commit + BuildTime = "20220907-153437" } App.Compiled = getBuildTime() if Version == "" { - Version = "0.0.0+None" + Version = "0.0.0" } App.Version = Version + if GitCommit == "" { + GitCommit = "out-of-tree" + } + if SentryDSN != "" { setupSentry() } @@ -73,7 +79,7 @@ func setupSentry() { EnableTracing: true, TracesSampleRate: 1.0, SendDefaultPII: true, - Release: Version, + Release: GitCommit, }) if err != nil { log.Fatalf("sentry.Init: %s", err)