forked from seatgeek/hashi-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (50 loc) · 1.67 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
# build config
BUILD_DIR ?= $(abspath build)
GET_GOARCH = $(word 2,$(subst -, ,$1))
GET_GOOS = $(word 1,$(subst -, ,$1))
GOBUILD ?= $(shell go env GOOS)-$(shell go env GOARCH)
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
VETARGS? =-all
$(BUILD_DIR):
mkdir -p $@
.PHONY: install
install:
go get github.com/kardianos/govendor
govendor sync
.PHONY: build
build: install
govendor sync
go install
.PHONY: fmt
fmt:
@echo "=> Running go fmt" ;
@if [ -n "`go fmt ${GOFILES_NOVENDOR}`" ]; then \
echo "[ERR] go fmt updated formatting. Please commit formatted code first."; \
exit 1; \
fi
.PHONY: vet
vet: fmt
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
go get golang.org/x/tools/cmd/vet; \
fi
@echo "=> Running go tool vet $(VETARGS) ${GOFILES_NOVENDOR}"
@go tool vet $(VETARGS) ${GOFILES_NOVENDOR} ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "[LINT] Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
fi
BINARIES = $(addprefix $(BUILD_DIR)/hashi-helper-, $(GOBUILD))
$(BINARIES): $(BUILD_DIR)/hashi-helper-%: $(BUILD_DIR)
@echo "=> building $@ ..."
GOOS=$(call GET_GOOS,$*) GOARCH=$(call GET_GOARCH,$*) CGO_ENABLED=0 govendor build -o $@
.PHONY: dist
dist: install fmt vet
@echo "=> building ..."
$(MAKE) -j $(BINARIES)
.PHONY: docker
docker:
@echo "=> build and push Docker image ..."
@docker login -u $(DOCKER_USER) -p $(DOCKER_PASS)
docker build -f Dockerfile -t seatgeek/hashi-helper:$(COMMIT) .
docker tag seatgeek/hashi-helper:$(COMMIT) seatgeek/hashi-helper:$(TAG)
docker push seatgeek/hashi-helper:$(TAG)