-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (36 loc) · 1.02 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
MODULE ?= github.com/askolesov/image-vault
PACKAGE ?= ./...
OUTPUT ?= build/
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null)
BRANCH ?= $(shell git symbolic-ref -q --short HEAD 2>/dev/null)
COMMIT_HASH ?= $(shell git rev-parse --short HEAD 2>/dev/null)
BUILD_DATE ?= $(shell date +%FT%T%z)
GOARGS += -v
LDFLAGS += -s -w -X ${MODULE}/pkg/buildinfo.version=${VERSION} \
-X ${MODULE}/pkg/buildinfo.commitHash=${COMMIT_HASH} \
-X ${MODULE}/pkg/buildinfo.buildDate=${BUILD_DATE} \
-X ${MODULE}/pkg/buildinfo.branch=${BRANCH}
.PHONY: run
run:
go run ${GOARGS} -tags "${GOTAGS}" -ldflags "${LDFLAGS}" ${PACKAGE}
.PHONY: build
build:
go build ${GOARGS} -tags "${GOTAGS}" -ldflags "${LDFLAGS}" -o ${OUTPUT} ${PACKAGE}
.PHONY: install
install:
go install ${GOARGS} -tags "${GOTAGS}" -ldflags "${LDFLAGS}" ${PACKAGE}
.PHONY: test
test:
go test -count=1 -v ./...
.PHONY: build-clean
build-clean:
rm -rf ${OUTPUT}
.PHONY: lint
lint:
golangci-lint run -v
.PHONY: pre-push
pre-push:
go mod tidy
make lint
make test
make build