From 891b539bf5e9acf4731287f40b965332ab6190e9 Mon Sep 17 00:00:00 2001 From: Ben Whaley Date: Tue, 16 Jul 2019 16:35:14 -0700 Subject: [PATCH] Bump version to 1.3.2 and move Version to a build time variable --- Makefile | 12 +++++++++--- ssmsh.go | 10 +++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 7edf3401..56dfcfe3 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) .PHONY: build test golint docs $(PROJECT) $(PKGS) vendor +VERSION := $(shell echo ${SSMSH_VERSION}) +ifeq "$(VERSION)" "" + $(error must define SSMSH_VERSION env var) +endif + + GOVERSION := $(shell go version | grep 1.12) ifeq "$(GOVERSION)" "" $(error must be running Go version 1.12.x) @@ -26,7 +32,7 @@ DEP := $(GOPATH)/bin/dep $(DEP): go get -u github.com/golang/dep -GO_LDFLAGS := -X $(shell go list ./$(PACKAGE)).GitCommit=$(GIT_COMMIT) +GO_LDFLAGS := -X $(shell go list ./$(PACKAGE)).GitCommit=$(GIT_COMMIT) -X main.Version=${VERSION} test: $(PKGS) @@ -46,9 +52,9 @@ vendor: $(DEP) build: go build -i -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE) $(PROJECT) build-linux: - GOOS=linux GOARCH=amd64 go build -o $(GOPATH)/bin/$(EXECUTABLE)-linux-amd64 + GOOS=linux GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-linux-amd64 build-darwin: - GOOS=darwin GOARCH=amd64 go build -o $(GOPATH)/bin/$(EXECUTABLE)-darwin-amd64 + GOOS=darwin GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-darwin-amd64 clean: rm -f $(GOPATH)/bin/$(EXECUTABLE) $(GOPATH)/bin/$(EXECUTABLE)-* diff --git a/ssmsh.go b/ssmsh.go index 60c2dbf9..d74d67ab 100644 --- a/ssmsh.go +++ b/ssmsh.go @@ -13,16 +13,16 @@ import ( "github.com/mattn/go-shellwords" ) -const version = "1.3.1" +var Version string func main() { - var _version bool + var version bool _fn := flag.String("file", "", "Read commands from file (use - for stdin)") - flag.BoolVar(&_version, "version", false, "Display the current version") + flag.BoolVar(&version, "version", false, "Display the current version") flag.Parse() - if _version { - fmt.Println("Version", version) + if version { + fmt.Println("Version", Version) os.Exit(0) }