-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (104 loc) · 3.41 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
GOPACKAGES = $(shell go list ./... | grep -v /vendor/)
GIT_DESCR = $(shell git describe --tags --always)
APP=costoflife
# build output folder
OUTPUTFOLDER = target
# docker image
DOCKER_REGISTRY = noandrea
DOCKER_IMAGE = costoflife
DOCKER_TAG = $(GIT_DESCR)
# build paramters
OS = linux
ARCH = amd64
# K8S
K8S_NAMESPACE = default
K8S_DEPLOYMENT = costoflife
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
default: build
build:
cargo build
build-dist:
@echo building release
cargo build --release
# @echo copy resources
# cp -r README.md LICENSE $(OUTPUTFOLDER)
@echo done
install: build-dist
mv target/release/$(APP) ~/Applications/bin
build-zip: build-dist
@echo build zip release
zip -rmT $(APP)-$(GIT_DESCR).zip $(OUTPUTFOLDER)
sha1sum $(APP)-$(GIT_DESCR).zip
@echo done
test:
RUST_BACKTRACE=1 cargo tarpaulin -o Lcov
test-wasm:
wasm-pack test --firefox --headless
wasm-pack test --node
test-all: test test-wasm
lint: lint-all
lint-all:
cargo fmt
# cargo fix
cargo clippy
clean:
@echo remove $(OUTPUTFOLDER) folder
rm -rf $(OUTPUTFOLDER)
rm -rf pkg
@echo done
docker: docker-build
docker-build:
@echo copy resources
docker build --build-arg DOCKER_TAG='$(GIT_DESCR)' -t $(DOCKER_IMAGE) .
@echo done
docker-push:
@echo push image
docker tag $(DOCKER_IMAGE):latest $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@echo done
docker-run:
docker run -p 2007:2007 $(DOCKER_IMAGE):latest
wasm-build:
wasm-pack build --release
wasm-publish: wasm-build
wasm-pack publish
publish:
cargo publish
publish-all: publish wasm-publish
k8s-deploy:
@echo deploy k8s
kubectl -n $(K8S_NAMESPACE) set image deployment/$(K8S_DEPLOYMENT) $(DOCKER_IMAGE)=$(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@echo done
k8s-rollback:
@echo deploy k8s
kubectl -n $(K8S_NAMESPACE) rollout undo deployment/$(K8S_DEPLOYMENT)
@echo done
changelog:
git-chglog --output CHANGELOG.md
git-release:
@echo making release
git tag $(GIT_DESCR)
git-chglog --output CHANGELOG.md
git tag $(GIT_DESCR) --delete
git add CHANGELOG.md && git commit -m "$(GIT_DESCR)" -m "Changelog: https://github.com/noandrea/$(APP)/blob/main/CHANGELOG.md"
@echo release complete
git-tag:
git tag -s -a "$(GIT_DESCR)" -m "Changelog: https://github.com/noandrea/$(APP)/blob/main/CHANGELOG.md"
_release-patch:
$(eval GIT_DESCR = $(shell git describe --tags | awk -F '("|")' '{ print($$1)}' | awk -F. '{$$NF = $$NF + 1;} 1' | sed 's/ /./g'))
cargo bump patch
git add Cargo.toml Cargo.lock
release-patch: _release-patch git-release
_release-minor:
$(eval GIT_DESCR = $(shell git describe --tags | awk -F '("|")' '{ print($$1)}' | awk -F. '{$$(NF-1) = $$(NF-1) + 1;} 1' | sed 's/ /./g' | awk -F. '{$$(NF) = 0;} 1' | sed 's/ /./g'))
cargo bump minor
git add Cargo.toml Cargo.lock
release-minor: _release-minor git-release
_release-major:
$(eval GIT_DESCR = $(shell git describe --tags | awk -F '("|")' '{ print($$1)}' | awk -F. '{$$(NF-2) = $$(NF-2) + 1;} 1' | sed 's/ /./g' | awk -F. '{$$(NF-1) = 0;} 1' | sed 's/ /./g' | awk -F. '{$$(NF) = 0;} 1' | sed 's/ /./g' ))
cargo bump major
git add Cargo.toml Cargo.lock
release-major: _release-major git-release