From 59ea2e018e05e7a4033d572f819f4a696ab74397 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 20 Feb 2019 21:56:33 +0100 Subject: add a "version" command with various outputs, including the git hash and tag --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Makefile') 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 -- cgit