-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
67 lines (47 loc) · 1.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
VERSION ?= snapshot
ifeq ($(VERSION), snapshot)
TAG = latest
else
TAG = $(VERSION)
endif
# This is important to export until we're on Go 1.13+ or packr can break
export GO111MODULE = on
MD5CMD = $(shell { command -v md5sum || command -v md5; } 2>/dev/null)
# GUARD is a function which calculates md5 sum for its
# argument variable name.
GUARD = $(1)_GUARD_$(shell echo $($(1)) | $(MD5CMD) | cut -d ' ' -f 1)
FIRSTGOPATH = $(firstword $(subst :, ,$(GOPATH)))
VERSION_TXT = signer/resources/templates/version.txt
GOSUMCHECK = $(shell $(MD5CMD) go.sum)
gosources = $(shell find . -type f -name "*.go" -print)
packr = signer/packrd/packed-packr.go signer/resources/resources-packr.go
all: tupelo
$(VERSION_TXT): $(call GUARD,VERSION)
mkdir -p signer/resources/templates
echo $(VERSION) > $@
$(call GUARD,VERSION):
rm -rf VERSION_GUARD_*
touch $@
$(FIRSTGOPATH)/bin/packr2:
GO111MODULE=off go get -u github.com/gobuffalo/packr/v2/packr2
$(packr): $(FIRSTGOPATH)/bin/packr2 $(VERSION_TXT)
$(FIRSTGOPATH)/bin/packr2
tupelo: $(packr) $(gosources) go.mod go.sum
go build -o tupelo ./signer/
lint: $(FIRSTGOPATH)/bin/golangci-lint $(packr)
$(FIRSTGOPATH)/bin/golangci-lint run --build-tags integration
$(FIRSTGOPATH)/bin/golangci-lint:
./scripts/download-golangci-lint.sh
test: $(packr) $(gosources) go.mod go.sum
go test -tags=integration ./...
docker-image: $(packr) $(gosources) Dockerfile .dockerignore
docker build -t quorumcontrol/tupelo:$(TAG) .
install: tupelo
cp tupelo $(FIRSTGOPATH)/bin/
clean: $(FIRSTGOPATH)/bin/packr2
$(FIRSTGOPATH)/bin/packr2 clean
go clean
github-prepare:
# mimic https://github.com/actions/docker/blob/b12ae68bebbb2781edb562c0260881a3f86963b4/tag/tag.rb#L39
VERSION=$(shell { echo $(GITHUB_REF) | rev | cut -d / -f 1 | rev; }) $(MAKE) $(packr)
.PHONY: all test ci-test docker-image clean install lint github-prepare generate