-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (30 loc) · 1.11 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
TAG=$(shell git describe --tags --always)
VERSION=$(TAG:v%=%)
REPO=jukeizu/selection
GO=GO111MODULE=on go
BUILD=GOARCH=amd64 $(GO) build -ldflags="-s -w -X main.Version=$(VERSION)"
PROTOFILES=$(wildcard .protobuf/selection/v1/*.proto)
PROTOPBDEST="../../../api/protobuf-spec"
PBFILES=$(patsubst %.proto,%.pb.go, $(PROTOFILES))
.PHONY: all deps test build build-linux docker-build docker-save docker-deploy proto clean $(PROTOFILES)
all: deps test build
deps:
$(GO) mod download
test:
$(GO) vet ./...
$(GO) test -v -race ./...
build:
$(BUILD) -o bin/selection-$(VERSION) ./cmd/...
build-linux:
CGO_ENABLED=0 GOOS=linux $(BUILD) -a -installsuffix cgo -o bin/selection ./cmd/...
docker-build:
docker build -t $(REPO):$(VERSION) .
docker-save:
mkdir -p bin && docker save -o bin/image.tar $(REPO):$(VERSION)
docker-deploy:
docker push $(REPO):$(VERSION)
proto: $(PBFILES)
%.pb.go: %.proto
cd $(dir $<) && mkdir -p $(PROTOPBDEST)/$(patsubst %.proto,%pb, $(notdir $<)) && protoc $(notdir $<) --go_out=plugins=grpc:$(PROTOPBDEST)/$(patsubst %.proto,%pb, $(notdir $<))
clean:
@find bin -type f ! -name '*.toml' -delete -print