From 13ca97e312443ca682764da7840ceb0cdee049a9 Mon Sep 17 00:00:00 2001 From: catatsuy Date: Wed, 30 Oct 2019 20:25:51 +0900 Subject: [PATCH] provide the version automatically --- .circleci/config.yml | 2 +- Makefile | 4 ++-- README.md | 2 -- cli/cli.go | 6 ++++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 198af9b..994db76 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: - run: make vet - run: make test - run: make bin/notify_slack - - run: make release + - run: make release version=${CIRCLE_TAG} - persist_to_workspace: root: release/ diff --git a/Makefile b/Makefile index bb9be07..b304a90 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ bin/output: cmd/output/main.go .PHONY: release release: - GOOS=linux go build -o notify_slack cmd/notify_slack/main.go + GOOS=linux go build -ldflags "-X github.com/catatsuy/notify_slack/cli.Version=${version}" -o notify_slack cmd/notify_slack/main.go tar cvzf release/notify_slack-linux-amd64.tar.gz notify_slack - GOOS=darwin go build -o notify_slack cmd/notify_slack/main.go + GOOS=darwin go build -ldflags "-X github.com/catatsuy/notify_slack/cli.Version=${version}" -o notify_slack cmd/notify_slack/main.go tar cvzf release/notify_slack-darwin-amd64.tar.gz notify_slack rm notify_slack diff --git a/README.md b/README.md index f5ce613..601ae9c 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,6 @@ It will be useful if you want to use it on a container. If you use it, you don't ## Release -Version of `cli/cli.go` will be updated. - When you execute the following command and give a tag, it will be released via CircleCI. ``` sh diff --git a/cli/cli.go b/cli/cli.go index 463c878..46f859a 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -17,9 +17,11 @@ import ( "github.com/catatsuy/notify_slack/throttle" ) -const ( - Version = "v0.4.1" +var ( + Version string +) +const ( ExitCodeOK = 0 ExitCodeParseFlagError = 1 ExitCodeFail = 1