From 4a29d459daf1d8ed89d19223a1479dc617db0bd5 Mon Sep 17 00:00:00 2001 From: Al Lefebvre Date: Mon, 30 Nov 2015 12:10:47 -0500 Subject: [PATCH 1/3] Added flag to display version number and exit --- README.md | 4 +++- main.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c2adc7ab3f..e851422bfc6 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,12 @@ go get github.com/grafana/grafana ### Building the backend ``` +/usr/local/go/src/github.com/grafana/grafana/ cd $GOPATH/src/github.com/grafana/grafana go run build.go setup (only needed once to install godep) godep restore (will pull down all golang lib dependencies in your current GOPATH) -go build . +go build -ldflags "-X main.build_date=`date +%Y-%m-%d` -X main.version=2.6.1 -X main.commit=`git rev-parse --verify HEAD`" + ``` ### Building frontend assets diff --git a/main.go b/main.go index 9639d432bea..4a052ea4934 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "io/ioutil" "os" "os/signal" @@ -27,6 +28,7 @@ import ( var version = "master" var commit = "NA" var buildstamp string +var build_date string var configFile = flag.String("config", "", "path to config file") var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory") @@ -38,6 +40,14 @@ func init() { } func main() { + + v := flag.Bool("v", false, "prints current version and exits") + flag.Parse() + if *v { + fmt.Printf("Version %s (commit: %s)\n", version, commit) + os.Exit(0) + } + buildstampInt64, _ := strconv.ParseInt(buildstamp, 10, 64) setting.BuildVersion = version From 20eb6df9e8fdb7c459b7dfcfc7d858859b2ae06c Mon Sep 17 00:00:00 2001 From: Al Lefebvre Date: Mon, 30 Nov 2015 12:24:14 -0500 Subject: [PATCH 2/3] Removed comment line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e851422bfc6..82e29011585 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ go get github.com/grafana/grafana ### Building the backend ``` -/usr/local/go/src/github.com/grafana/grafana/ cd $GOPATH/src/github.com/grafana/grafana go run build.go setup (only needed once to install godep) godep restore (will pull down all golang lib dependencies in your current GOPATH) From 8deb6d9246f76a8799469b220d0feb082724eb4c Mon Sep 17 00:00:00 2001 From: Al Lefebvre Date: Mon, 30 Nov 2015 13:09:29 -0500 Subject: [PATCH 3/3] Updated README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 82e29011585..d64c51148b8 100644 --- a/README.md +++ b/README.md @@ -85,11 +85,12 @@ go get github.com/grafana/grafana ``` ### Building the backend +Replace X.Y.Z by actual version number. ``` cd $GOPATH/src/github.com/grafana/grafana go run build.go setup (only needed once to install godep) godep restore (will pull down all golang lib dependencies in your current GOPATH) -go build -ldflags "-X main.build_date=`date +%Y-%m-%d` -X main.version=2.6.1 -X main.commit=`git rev-parse --verify HEAD`" +go build -ldflags "-X main.build_date=`date +%Y-%m-%d` -X main.version=X.Y.Z -X main.commit=`git rev-parse --verify HEAD`" ```