diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad80dc0..79d11f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,13 @@ build executable: <<: *setup_go_environment stage: build script: - - env GOOS=linux go build -o $CI_PROJECT_DIR/minecraft-skinsystem main.go + - export VERSION="${CI_BUILD_TAG:-dev-$CI_BUILD_REF_NAME-${CI_BUILD_REF:0:8}+build-$CI_BUILD_ID}" + - > + env GOOS=linux + go build + -o $CI_PROJECT_DIR/minecraft-skinsystem + -ldflags "-X ${CI_PROJECT_NAMESPACE}/bootstrap.version=${VERSION}" + main.go artifacts: name: "${CI_JOB_STAGE} executable" paths: diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 0a35f1b..e0048a1 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -15,6 +15,12 @@ import ( "elyby/minecraft-skinsystem/logger/receivers/sentry" ) +var version = "" + +func GetVersion() string { + return version +} + func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) { wd.AddReceiver(ansi.New(true, true, false)) if statsdAddr != "" { @@ -38,9 +44,12 @@ func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) { return nil, err } - ravenClient.SetRelease("1.3.2") // TODO: нужно как-то записывать версию во время билда ravenClient.SetEnvironment("production") ravenClient.SetDefaultLoggerName("sentry-watchdog-receiver") + programVersion := GetVersion() + if programVersion != "" { + raven.SetRelease(programVersion) + } sentryReceiver, err := sentry.NewReceiverWithCustomRaven(ravenClient, &sentry.Config{ MinLevel: "warn",