Добавлена генерация версии при сборке проекта

This commit is contained in:
ErickSkrauch 2017-09-02 21:37:16 +03:00
parent cf99a0eab2
commit 340b24d862
2 changed files with 17 additions and 2 deletions

View File

@ -38,7 +38,13 @@ build executable:
<<: *setup_go_environment <<: *setup_go_environment
stage: build stage: build
script: 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: artifacts:
name: "${CI_JOB_STAGE} executable" name: "${CI_JOB_STAGE} executable"
paths: paths:

View File

@ -15,6 +15,12 @@ import (
"elyby/minecraft-skinsystem/logger/receivers/sentry" "elyby/minecraft-skinsystem/logger/receivers/sentry"
) )
var version = ""
func GetVersion() string {
return version
}
func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) { func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) {
wd.AddReceiver(ansi.New(true, true, false)) wd.AddReceiver(ansi.New(true, true, false))
if statsdAddr != "" { if statsdAddr != "" {
@ -38,9 +44,12 @@ func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) {
return nil, err return nil, err
} }
ravenClient.SetRelease("1.3.2") // TODO: нужно как-то записывать версию во время билда
ravenClient.SetEnvironment("production") ravenClient.SetEnvironment("production")
ravenClient.SetDefaultLoggerName("sentry-watchdog-receiver") ravenClient.SetDefaultLoggerName("sentry-watchdog-receiver")
programVersion := GetVersion()
if programVersion != "" {
raven.SetRelease(programVersion)
}
sentryReceiver, err := sentry.NewReceiverWithCustomRaven(ravenClient, &sentry.Config{ sentryReceiver, err := sentry.NewReceiverWithCustomRaven(ravenClient, &sentry.Config{
MinLevel: "warn", MinLevel: "warn",