-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeFile
100 lines (85 loc) · 3.36 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Usage:
# make # compile all binary
# make clean # remove ALL binaries and objects
# make release # add git TAG and push
GITHUB_REPO_OWNER := seidu.abdulai
GITHUB_REPO_NAME := exchange_rate
GITHUB_RELEASES_UI_URL := https://github.com/$(GITHUB_REPO_OWNER)/$(GITHUB_REPO_NAME)/releases
GITHUB_RELEASES_API_URL := https://api.github.com/repos/$(GITHUB_REPO_OWNER)/$(GITHUB_REPO_NAME)/releases
GITHUB_RELEASE_ASSET_URL := https://uploads.github.com/repos/$(GITHUB_REPO_OWNER)/$(GITHUB_REPO_NAME)/releases
GITHUB_DEPLOY_API_URL := https://api.github.com/repos/$(GITHUB_REPO_OWNER)/$(GITHUB_REPO_NAME)/deployments
DOCKER_REGISTRY := docker.pkg.github.com
# DOCKER_REGISTRY := us.gcr.io
DOCKER_CONTEXT_PATH := $(GITHUB_REPO_OWNER)/$(GITHUB_REPO_NAME)
# DOCKER_REGISTRY := docker.io
# DOCKER_CONTEXT_PATH := seidu.abdulai
GO_MICRO_VERSION := latest
VERSION := $(shell git describe --tags || echo "HEAD")
GOPATH := $(shell go env GOPATH)
CODECOV_FILE := build/coverage.txt
TIMEOUT := 60s
# don't override
GIT_TAG := $(shell git describe --tags --abbrev=0 --always --match "v*")
GIT_DIRTY := $(shell git status --porcelain 2> /dev/null)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GOPATH:=$(shell go env GOPATH)
.PHONY: init
init:
go get -u google.golang.org/protobuf/proto@latest
go get -u google.golang.org/protobuf/cmd/protoc-gen-go@latest
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go get github.com/micro/micro/v3/cmd/protoc-gen-micro@latest
go get github.com/google/gnostic/cmd/protoc-gen-openapi@latest
update_deps:
go mod verify
go mod tidy
.PHONY: proto
proto:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=. --go-grpc_out=. proto/exchange_rate.proto
docs:
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=. proto/exchange_rate.proto
@redoc-cli bundle api-exchange_rate.json --options.theme.colors.primary.main=orange
.PHONY: build
build:
go build -o exchange_rate *.go
.PHONY: test
test:
go test -v ./... -cover
.PHONY: docker
docker:
docker build . -t exchange_rate:latest
docker_clean:
@echo "Cleaning dangling images..."
@docker images -f "dangling=true" -q | xargs docker rmi
@echo "Removing microservice images..."
@docker images -f "label=org.label-schema.vendor=sumo" -q | xargs docker rmi
@echo "Pruneing images..."
@docker image prune -f
docker_push:
@echo "Piblishing images with VCS_REF=$(shell git rev-parse --short HEAD)"
@docker images -f "label=org.label-schema.vcs-ref=$(shell git rev-parse --short HEAD)" --format {{.Repository}}:{{.Tag}} | \
while read -r image; do \
echo Now pushing $$image; \
docker push $$image; \
done;
.PHONY: git
ifeq ($(VERSION),)
VERSION:=$(shell git describe --tags --abbrev=0 | awk -F . '{OFS="."; $$NF+=1; print}')
endif
#tags:
# @git "checkout integration "\
# @echo $(VERSION) \
# @git tag $(VERSION) \
# @git push --tags
tag:
@if [ $$(git rev-list $$(git describe --abbrev=0 --tags)..HEAD --count) -gt 0 ]; then \
if [ $$(git log -n 1 --oneline $$(git describe --abbrev=0 --tags)..HEAD CHANGELOG.md | wc -l) -gt 0 ]; then \
git tag $$(python setup.py --version) && git push --tags || echo 'Version already released, update your version!'
else \
echo "CHANGELOG not updated since last release!"; \
exit 1; \
fi; \
else \
echo "No commits since last release!"; \
exit 1;\
fi