forked from pedropombeiro/qnapexporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
31 lines (25 loc) · 904 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
PKG = github.com/pedropombeiro/qnapexporter
VERSION_PKG = $(PKG)/lib/utils
PACKAGE_VERSION ?= dev
REVISION := $(shell git rev-parse --short=8 HEAD || echo unknown)
BRANCH := $(shell git show-ref | grep "$(REVISION)" | grep -v HEAD | awk '{print $$2}' | sed 's|refs/remotes/origin/||' | sed 's|refs/heads/||' | sort | head -n 1)
BUILT := $(shell date -u +%Y-%m-%dT%H:%M:%S%z)
GO_LDFLAGS ?= -X $(VERSION_PKG).REVISION=$(REVISION) -X $(VERSION_PKG).BUILT=$(BUILT) \
-X $(VERSION_PKG).BRANCH=$(BRANCH) -X $(VERSION_PKG).VERSION=$(PACKAGE_VERSION) \
-s -w
.PHONY: build
build:
@ mkdir -p ./bin
go build -mod=readonly -ldflags "$(GO_LDFLAGS)" -o bin/qnapexporter .
.PHONY: test
test:
@ go test ./...
.PHONY: mocks
mocks:
@ find . -name mock_*.go -delete
@ mockery --dir=. --recursive --all --inpackage
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: all clean