From 5b27942797dcb6e4d9483ea41525cdb127d8af87 Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Sun, 13 Mar 2016 02:05:09 +0300 Subject: [PATCH] Added versions --- Makefile | 14 ++++++++------ grvm.go | 3 +++ install.sh | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 25ff666..81dbe01 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ -.PHONY: all clean dist +.PHONY: all clean dist version -all: deps crosscompile dist +VERSION := $(shell if [ -z "$$TRAVIS_TAG" ]; then echo "dev"; else echo "$$TRAVIS_TAG" | tail -c +2; fi) + +all: deps crosscompile version dist deps: go get github.com/mitchellh/gox @@ -10,10 +12,10 @@ build: go build grvm.go crosscompile: - gox --osarch="linux/amd64" --output="crosscompile/linux_amd64_grvm" - gox --osarch="linux/386" --output="crosscompile/linux_386_grvm" - gox --osarch="linux/arm" --output="crosscompile/linux_arm_grvm" - gox --osarch="darwin/amd64" --output="crosscompile/darwin_amd64_grvm" + gox --osarch="linux/amd64" --output="crosscompile/linux_amd64_grvm" --ldflags='-X main.version=${VERSION}' + gox --osarch="linux/386" --output="crosscompile/linux_386_grvm" --ldflags='-X main.version=${VERSION}' + gox --osarch="linux/arm" --output="crosscompile/linux_arm_grvm" --ldflags='-X main.version=${VERSION}' + gox --osarch="darwin/amd64" --output="crosscompile/darwin_amd64_grvm" --ldflags='-X main.version=${VERSION}' dist: @for target in crosscompile/*_grvm; do \ diff --git a/grvm.go b/grvm.go index 56a4fc7..efaa834 100644 --- a/grvm.go +++ b/grvm.go @@ -15,6 +15,8 @@ const ( rubyBuildRepo = "https://github.com/rbenv/ruby-build.git" ) +var version = "" + var currentHome = os.Getenv("HOME") var grvmRuby = os.Getenv("grvm_ruby") var grvmDirectory = fmt.Sprintf("%s/.grvm", currentHome) @@ -39,6 +41,7 @@ func main() { app := cli.NewApp() app.Name = "GRVM" app.Usage = "GRVM" + app.Version = version app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "shell, s", diff --git a/install.sh b/install.sh index 8e34f97..2ffa754 100644 --- a/install.sh +++ b/install.sh @@ -46,7 +46,7 @@ function tmpCleanup { case $1 in "devinstall") - go build grvm.go + go build --ldflags '-X main.version=dev' grvm.go rm -rf $HOME/.grvm/bin rm -rf $HOME/.grvm/scripts mkdir -p $HOME/.grvm/bin