diff --git a/Makefile b/Makefile index aba60c45..e7b5e693 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ REPOROOT = $(abspath $(dir $(THIS_MAKEFILE))) TEST_PACKAGES = $(subst $(REPOROOT)/src/,,$(shell go list -f '{{if gt (len .TestGoFiles) 0}}{{.Dir}}{{end}}' ./...)) export GOPATH := $(REPOROOT)/ +export VERSION ?= DEVELOPMENT export GOCMD ?= go .PHONY: all @@ -16,7 +17,7 @@ clean: .PHONY: ankh ankh: - cd $(REPOROOT)/src/ankh/cmd/ankh; $(GOCMD) install + cd $(REPOROOT)/src/ankh/cmd/ankh; $(GOCMD) install -ldflags "-X main.AnkhBuildVersion=$(VERSION)" .PHONY: install install: ankh diff --git a/release.bash b/release.bash index 30efb69d..bfa61ca4 100755 --- a/release.bash +++ b/release.bash @@ -1,8 +1,14 @@ #!/bin/bash +if [ -z "$VERSION" ] ; then + echo "Must provide VERSION" + exit 1 +fi + +make clean || exit 1 + release_dir=release mkdir -p $release_dir -rm -f $release_dir/* function release() { export GOOS=$1 diff --git a/src/ankh/cmd/ankh/main.go b/src/ankh/cmd/ankh/main.go index 2165edf2..23ff5d37 100644 --- a/src/ankh/cmd/ankh/main.go +++ b/src/ankh/cmd/ankh/main.go @@ -23,6 +23,8 @@ import ( "ankh/util" ) +var AnkhBuildVersion string + var log = logrus.New() func logExecuteAnkhFile(ctx *ankh.ExecutionContext, ankhFile ankh.AnkhFile) { @@ -331,6 +333,11 @@ func main() { }) }) + app.Command("version", "Show version info", func(cmd *cli.Cmd) { + fmt.Println(AnkhBuildVersion) + os.Exit(0) + }) + app.Run(os.Args) }