chore: use git commit hash instead of version in sentry
This commit is contained in:
parent
8fc7181bec
commit
085202c174
4
Makefile
4
Makefile
@ -2,10 +2,12 @@ GO := go
|
|||||||
|
|
||||||
PKG_BASE := $(shell head -n 1 go.mod | awk '{print $$2}')
|
PKG_BASE := $(shell head -n 1 go.mod | awk '{print $$2}')
|
||||||
BUILD_TIME := $(shell date -u '+%Y%m%d-%I%M%S')
|
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.BuildTime=$(BUILD_TIME)
|
||||||
LDFLAGS += -X $(PKG_BASE)/cmd.Version=$(VERSION)
|
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 += -X $(PKG_BASE)/cmd.SentryDSN=$(shell cat dsn.txt)
|
||||||
LDFLAGS += -s -w
|
LDFLAGS += -s -w
|
||||||
|
|
||||||
|
@ -39,20 +39,26 @@ var App = &cli.App{
|
|||||||
var (
|
var (
|
||||||
BuildTime string
|
BuildTime string
|
||||||
Version string
|
Version string
|
||||||
|
GitCommit string
|
||||||
SentryDSN string
|
SentryDSN string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if BuildTime == "" {
|
if BuildTime == "" {
|
||||||
BuildTime = "2022-09-06-01-00-00"
|
// First Commit
|
||||||
|
BuildTime = "20220907-153437"
|
||||||
}
|
}
|
||||||
App.Compiled = getBuildTime()
|
App.Compiled = getBuildTime()
|
||||||
|
|
||||||
if Version == "" {
|
if Version == "" {
|
||||||
Version = "0.0.0+None"
|
Version = "0.0.0"
|
||||||
}
|
}
|
||||||
App.Version = Version
|
App.Version = Version
|
||||||
|
|
||||||
|
if GitCommit == "" {
|
||||||
|
GitCommit = "out-of-tree"
|
||||||
|
}
|
||||||
|
|
||||||
if SentryDSN != "" {
|
if SentryDSN != "" {
|
||||||
setupSentry()
|
setupSentry()
|
||||||
}
|
}
|
||||||
@ -73,7 +79,7 @@ func setupSentry() {
|
|||||||
EnableTracing: true,
|
EnableTracing: true,
|
||||||
TracesSampleRate: 1.0,
|
TracesSampleRate: 1.0,
|
||||||
SendDefaultPII: true,
|
SendDefaultPII: true,
|
||||||
Release: Version,
|
Release: GitCommit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("sentry.Init: %s", err)
|
log.Fatalf("sentry.Init: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user