diff --git a/.drone.yml b/.drone.yml index c197b50..f9fc97c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ clone: pipeline: test: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true secrets: [ telegram_token, telegram_to ] commands: @@ -22,28 +22,28 @@ pipeline: - make coverage build_linux_amd64: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true group: build commands: - make build_linux_amd64 build_linux_i386: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true group: build commands: - make build_linux_i386 build_linux_arm64: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true group: build commands: - make build_linux_arm64 build_linux_arm: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true group: build commands: @@ -58,7 +58,7 @@ pipeline: event: [ push, pull_request ] release: - image: appleboy/golang-testing + image: appleboy/golang-testing:1.9.2 pull: true commands: - make release diff --git a/Makefile b/Makefile index 6e62308..b177482 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ PACKAGES ?= $(shell go list ./... | grep -v /vendor/) GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") SOURCES ?= $(shell find . -name "*.go" -type f) TAGS ?= -LDFLAGS ?= -X 'main.Version=$(VERSION)' +LDFLAGS ?= -X 'main.Version=$(VERSION)' -X 'main.BuildNum=$(DRONE_BUILD_NUMBER)' TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir') ifneq ($(shell uname), Darwin) diff --git a/main.go b/main.go index 3c159d5..ea5b524 100644 --- a/main.go +++ b/main.go @@ -10,14 +10,16 @@ import ( ) // Version set at compile-time -var Version string +var ( + Version string + BuildNum string +) func main() { app := cli.NewApp() app.Name = "telegram plugin" app.Usage = "telegram plugin" app.Action = run - app.Version = Version app.Flags = []cli.Flag{ cli.StringFlag{ Name: "token", @@ -185,6 +187,12 @@ func main() { }, } + app.Version = Version + + if BuildNum != "" { + app.Version = app.Version + "+" + BuildNum + } + if err := app.Run(os.Args); err != nil { log.Println(err) }