Added fallback for git version failure, make uninstall

This commit is contained in:
asdf 2019-09-24 20:52:38 +10:00
parent 94835f416a
commit bd518fdeb2
2 changed files with 14 additions and 9 deletions

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.1

View File

@ -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)