-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
75 lines (59 loc) · 2.76 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
68
69
70
71
72
73
74
75
.PHONY: deps clean build lint changelog snapshot release signer signer-proto
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
GO ?= latest
BINARY = ghub
MAIN = $(shell pwd)/cmd/main.go
BUILDDIR = $(shell pwd)/build
VERSION ?= 0.0.1
GITREV = $(shell git rev-parse --short HEAD)
BUILDTIME = $(shell date +'%FT%TZ%z')
LDFLAGS=-ldflags '-X main.version=${VERSION} -X main.commit=${GITREV} -X main.date=${BUILDTIME}'
GO_BUILDER_VERSION=v1.15.1
default: build
deps:
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u github.com/goreleaser/goreleaser
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
go get -u golang.org/x/tools/cmd/goimports
build:
go build ${LDFLAGS} -o $(BUILDDIR)/${BINARY} $(MAIN)
@echo 'Build $(BINARY) done.'
changelog:
git-chglog $(VERSION) > CHANGELOG.md
@cat assets/footer.txt >> CHANGELOG.md
clean:
rm -rf $(BUILDDIR)/
lint:
golangci-lint run --fix
style:
gofmt -w .
goimports -local github.com/qlcchain/qlc-hub -w .
snapshot:
docker run --rm --privileged \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/qlc-hub \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /qlc-hub \
goreng/golang-cross:$(GO_BUILDER_VERSION) --snapshot --rm-dist
release: changelog
docker run --rm --privileged \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/qlc-hub \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /qlc-hub \
goreng/golang-cross:$(GO_BUILDER_VERSION) --rm-dist --debug --release-notes=CHANGELOG.md
hub-proto:
protoc -I$(GOPATH)/src -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I=$(shell pwd)/grpc/proto/ --go_out=plugins=grpc:$(shell pwd)/grpc/proto $(shell pwd)/grpc/proto/types.proto
protoc -I$(GOPATH)/src -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I=$(shell pwd)/grpc/proto/ --grpc-gateway_out=logtostderr=true:$(shell pwd)/grpc/proto $(shell pwd)/grpc/proto/types.proto
protoc -I$(GOPATH)/src -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I=$(shell pwd)/grpc/proto/ --swagger_out=logtostderr=true:$(shell pwd)/docs $(shell pwd)/grpc/proto/types.proto
signer-proto:
protoc -I$(GOPATH)/src -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I=$(shell pwd)/grpc/proto/ --go_out=plugins=grpc:$(shell pwd)/grpc/proto $(shell pwd)/grpc/proto/signer.proto
signer:
go build ${LDFLAGS} -o $(BUILDDIR)/signer $(shell pwd)/cmd/signer/main.go
@echo 'Build signer done.'