feat(docker): Add build number.

This commit is contained in:
Bo-Yi Wu 2017-12-19 10:12:27 +08:00
parent fdc76c4f08
commit 8b5adb6493
3 changed files with 17 additions and 9 deletions

View File

@ -10,7 +10,7 @@ clone:
pipeline: pipeline:
test: test:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
secrets: [ telegram_token, telegram_to ] secrets: [ telegram_token, telegram_to ]
commands: commands:
@ -22,28 +22,28 @@ pipeline:
- make coverage - make coverage
build_linux_amd64: build_linux_amd64:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
group: build group: build
commands: commands:
- make build_linux_amd64 - make build_linux_amd64
build_linux_i386: build_linux_i386:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
group: build group: build
commands: commands:
- make build_linux_i386 - make build_linux_i386
build_linux_arm64: build_linux_arm64:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
group: build group: build
commands: commands:
- make build_linux_arm64 - make build_linux_arm64
build_linux_arm: build_linux_arm:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
group: build group: build
commands: commands:
@ -58,7 +58,7 @@ pipeline:
event: [ push, pull_request ] event: [ push, pull_request ]
release: release:
image: appleboy/golang-testing image: appleboy/golang-testing:1.9.2
pull: true pull: true
commands: commands:
- make release - make release

View File

@ -11,7 +11,7 @@ PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
SOURCES ?= $(shell find . -name "*.go" -type f) SOURCES ?= $(shell find . -name "*.go" -type f)
TAGS ?= 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') TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir')
ifneq ($(shell uname), Darwin) ifneq ($(shell uname), Darwin)

12
main.go
View File

@ -10,14 +10,16 @@ import (
) )
// Version set at compile-time // Version set at compile-time
var Version string var (
Version string
BuildNum string
)
func main() { func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "telegram plugin" app.Name = "telegram plugin"
app.Usage = "telegram plugin" app.Usage = "telegram plugin"
app.Action = run app.Action = run
app.Version = Version
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "token", 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 { if err := app.Run(os.Args); err != nil {
log.Println(err) log.Println(err)
} }