diff --git a/Makefile b/Makefile index 35b9308..2239268 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,22 @@ -package = github.com/cultureamp/cfparams +PACKAGE = github.com/cultureamp/cfparams +VERSION = $(shell git describe --tags --candidates=1 --dirty) +FLAGS=-X main.Version=$(VERSION) -s -w + +cfparams: main.go + go build -ldflags="$(FLAGS)" + +.PHONY: install +install: + go install -ldflags="$(FLAGS)" $(PACKAGE) .PHONY: release -release: cfparams-darwin-amd64.gz cfparams-linux-amd64.gz +release: cfparams-$(VERSION)-darwin-amd64.gz cfparams-$(VERSION)-linux-amd64.gz %.gz: % gzip $< %-darwin-amd64: - GOOS=darwin GOARCH=amd64 go build -o $@ $(package) + GOOS=darwin GOARCH=amd64 go build -ldflags="$(FLAGS)" -o $@ $(PACKAGE) %-linux-amd64: - GOOS=linux GOARCH=amd64 go build -o $@ $(package) + GOOS=linux GOARCH=amd64 go build -ldflags="$(FLAGS)" -o $@ $(PACKAGE) diff --git a/main.go b/main.go index bac9b29..66a90ab 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,9 @@ import ( yaml "gopkg.in/yaml.v2" ) +// see Makefile +var Version = "dev" + type Input struct { TemplateBody []byte AcceptDefaults bool @@ -46,7 +49,8 @@ func main() { var tplFile, paramFile string flag.Usage = func() { - fmt.Fprintf(os.Stderr, "\nUsage: %s [flags] [Key=value ...]\n\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "cfparams %s\n\n", Version) + fmt.Fprintf(os.Stderr, "Usage: %s [flags] [Key=value ...]\n\n", os.Args[0]) fmt.Fprintf(os.Stderr, "Produces JSON suitable for `aws cloudformation` CLI.\n\n") flag.PrintDefaults() }