Added fallback for git version failure, make uninstall
This commit is contained in:
parent
94835f416a
commit
bd518fdeb2
22
makefile
22
makefile
|
@ -1,11 +1,17 @@
|
||||||
BINARY := gfu
|
BINARY := gfu
|
||||||
PKGS := $(shell go list ./... |grep -v /vendor)
|
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
|
#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
|
#-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:
|
build:
|
||||||
go build ${LDFLAGS} -o ${BINARY}
|
go build ${LDFLAGS} -o ${BINARY}
|
||||||
|
@ -14,12 +20,10 @@ build:
|
||||||
install:
|
install:
|
||||||
go install ${LDFLAGS}
|
go install ${LDFLAGS}
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
go clean -i
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
go clean
|
go clean
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test:
|
|
||||||
go test $(PKGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue