From bd518fdeb2973279ece9a12d0c15a0ce1620c0c9 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 24 Sep 2019 20:52:38 +1000 Subject: [PATCH] Added fallback for git version failure, make uninstall --- VERSION | 1 + makefile | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..49d5957 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1 diff --git a/makefile b/makefile index 628f638..ab16706 100644 --- a/makefile +++ b/makefile @@ -1,11 +1,17 @@ BINARY := gfu PKGS := $(shell go list ./... |grep -v /vendor) -VERSION := $(shell git describe --tags) -BUILD := $(shell date -Iminutes) -LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD}" +# version checks git tags. if any errors, they are discarded, and the version is +# read from the VERSION file +VERSION := $(shell git describe --tags 2> /dev/null) +ifeq ($(VERSION),) + VERSION := $(shell cat VERSION) +endif +BUILD := $(shell date -Iminutes) + #ldflags for versioning info: https://stackoverflow.com/questions/11354518/application-auto-build-versioning #-s flag info: https://blog.spiralscout.com/using-w-and-s-flags-in-golang-97ae59b50e26 +LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD}" build: go build ${LDFLAGS} -o ${BINARY} @@ -14,12 +20,10 @@ build: install: go install ${LDFLAGS} +.PHONY: uninstall +uninstall: + go clean -i + .PHONY: clean clean: go clean - -.PHONY: test -test: - go test $(PKGS) - -