-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.example
64 lines (54 loc) · 1.77 KB
/
Makefile.example
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
export SHELL := /bin/sh
LOCAL_BIN := $(CURDIR)/.bin
OAPI_CODEGEN_VERSION := v2.2.0
OAPI_CODEGEN_BIN=$(LOCAL_BIN)/oapi-codegen
.PHONY: contracts-generate
contracts-generate:
cd api && $(OAPI_CODEGEN_BIN) -config playground-cfg.yaml api.yaml
cd api && $(OAPI_CODEGEN_BIN) -config sandbox-cfg.yaml api.yaml
.PHONY: install-oapi-codegen
install-oapi-codegen:
$(call fn_install_goutil,github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen,$(OAPI_CODEGEN_VERSION),$(OAPI_CODEGEN_BIN),"-tags=''")
define fn_install_goutil
@[ ! -f $(3)@$(2) ] \
|| exit 0 \
&& echo "Install $(1) ..." \
&& tmp=$$(mktemp -d) \
&& cd $$tmp \
&& echo "Module: $(1)" \
&& echo "Version: $(2)" \
&& echo "Binary: $(3)" \
&& echo "Temp: $$tmp" \
&& go mod init temp && go get -d $(1)@$(2) && go build $(4) -o $(3)@$(2) $(1) \
&& ln -sf $(3)@$(2) $(3) \
&& rm -rf $$tmp \
&& echo "$(3) installed!" \
&& echo "********************************"
endef
.PHONY: lint-play
lint-play:
docker run -t --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.63.4 golangci-lint run -v
.PHONY: lint-sand
lint-sand:
docker run -t --rm -v $(PWD)/sandbox:/app -v $(PWD)/.golangci.yml:/app/.golangci.yml -w /app golangci/golangci-lint:v1.63.4 golangci-lint run -v
.PHONY: lint
lint:
make lint-play
make lint-sand
VERSION := $(shell git tag --sort=-v:refname | head -n1)
NEW_TAG_FIX := $(shell echo $(VERSION) | awk -F. '{print $$1"."$$2"."$$3+1}')
NEW_TAG_MINOR := $(shell echo $(VERSION) | awk -F. '{print $$1"."$$2+1"."0}')
.PHONY: tag-fix
tag-fix:
echo $(NEW_TAG_FIX)
git checkout main
git pull origin main
git tag $(NEW_TAG_FIX)
git push origin $(NEW_TAG_FIX)
.PHONY: tag-minor
tag-minor:
echo $(NEW_TAG_MINOR)
git checkout main
git pull origin main
git tag $(NEW_TAG_MINOR)
git push origin $(NEW_TAG_MINOR)