From 6312eb91bee05171d97cecd509be115b2c6b6477 Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Sat, 6 May 2017 12:37:48 +0200 Subject: [PATCH 1/3] Change "make build" to set GitCommit variable As described above. --- Makefile | 3 ++- version/version.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e11152fce..0f8268a49 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ install: get_vendor_deps @go install ./cmd/tendermint build: - go build -o build/tendermint ./cmd/tendermint + go build --ldflags '-extldflags "-static"' \ + --ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse HEAD`" -o build/tendermint ./cmd/tendermint/ build_race: go build -race -o build/tendermint ./cmd/tendermint diff --git a/version/version.go b/version/version.go index fab2a05b7..ed7e46d55 100644 --- a/version/version.go +++ b/version/version.go @@ -4,4 +4,4 @@ const Maj = "0" const Min = "10" const Fix = "0" -const Version = "0.10.0" +const Version = Maj + "." + Min + "." + Fix From 8c91014cd8e832326b26c54b73d47dcb944139f0 Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 9 May 2017 11:37:59 +0200 Subject: [PATCH 2/3] Add git commit hash to version. --- Makefile | 2 +- version/version.go | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f8268a49..2c38119e4 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ TMHOME = $${TMHOME:-$$HOME/.tendermint} all: install test install: get_vendor_deps - @go install ./cmd/tendermint + @go install --ldflags '-extldflags "-static"' ./cmd/tendermint build: go build --ldflags '-extldflags "-static"' \ diff --git a/version/version.go b/version/version.go index ed7e46d55..8056ac708 100644 --- a/version/version.go +++ b/version/version.go @@ -1,7 +1,25 @@ package version +import ( + "fmt" +) + const Maj = "0" const Min = "10" const Fix = "0" -const Version = Maj + "." + Min + "." + Fix +var ( + // The full version string + Version = "0.10.0" + + // GitCommit is set with --ldflags "-X main.gitCommit=$(git rev-parse HEAD)" + GitCommit string +) + +func init() { + Version = fmt.Sprintf("%d.%d.%d", Maj, Min, Fix) + + if GitCommit != "" { + Version += "-" + GitCommit[:8] + } +} From cd3c3c3bad4092f80e222c72678e5428c290dda9 Mon Sep 17 00:00:00 2001 From: Adrian Brink Date: Tue, 9 May 2017 11:39:46 +0200 Subject: [PATCH 3/3] Modify makefile --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2c38119e4..7848e4785 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,11 @@ TMHOME = $${TMHOME:-$$HOME/.tendermint} all: install test install: get_vendor_deps - @go install --ldflags '-extldflags "-static"' ./cmd/tendermint + @go install --ldflags '-extldflags "-static"' \ + --ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse HEAD`" ./cmd/tendermint build: - go build --ldflags '-extldflags "-static"' \ + go build \ --ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse HEAD`" -o build/tendermint ./cmd/tendermint/ build_race: