aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMichael Muré <michael.mure@consensys.net>2019-02-20 21:56:33 +0100
committerMichael Muré <michael.mure@consensys.net>2019-02-20 21:56:33 +0100
commit59ea2e018e05e7a4033d572f819f4a696ab74397 (patch)
tree01a427bfc2f67208e1801e8e06a934d91eb9a777 /Makefile
parent09692456c7a5491b37a22d72e652de66ecc8d4e7 (diff)
downloadgit-bug-59ea2e018e05e7a4033d572f819f4a696ab74397.tar.gz
add a "version" command with various outputs, including the git hash and tag
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 17275db0..3c6207c7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,21 @@
all: build
+GIT_COMMIT:=$(shell git rev-list -1 HEAD)
+GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags)
+GIT_EXACT_TAG:=$(shell git name-rev --name-only --tags HEAD)
+COMMANDS_PATH:=github.com/MichaelMure/git-bug/commands
+LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit=${GIT_COMMIT} \
+ -X ${COMMANDS_PATH}.GitLastTag=${GIT_LAST_TAG} \
+ -X ${COMMANDS_PATH}.GitExactTag=${GIT_EXACT_TAG}
+
build:
go generate
- go build .
+ go build -ldflags "$(LDFLAGS)" .
# produce a build debugger friendly
debug-build:
go generate
- go build -gcflags=all="-N -l" .
+ go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
install:
go generate