forked from zeusro/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (53 loc) · 1.42 KB
/
Makefile
File metadata and controls
67 lines (53 loc) · 1.42 KB
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
now := $(shell date)
PREFIX ?= zeusro
APP_NAME ?= $app:latest
IMAGE ?= $(PREFIX)/$(APP_NAME)
MIRROR_IMAGE ?= registry.cn-shenzhen.aliyuncs.com/mirror/$app:latest
MODULE ?= $org/$project-name
ARCH ?= amd64
auto_commit:
git add .
git commit -am "$(now)"
# git remote add template git@github.com:zeusro/go-template.git
# git pull template master
git pull
git push
buildAndRun:
GOARCH=$(ARCH) CGO_ENABLED=0 go build
# ./$app
fix-dep:
go mod tidy
go mod vendor
# usage: dep="github.com/stretchr/testify/assert" make get
get:
go get -u -v $(dep)
go mod tidy && go mod verify && go mod vendor
init:
@if [ -z "$(project)" ]; then \
echo "❌ 请先设置 project 环境变量,例如:make init project=dir-monitor"; \
exit 1; \
else \
echo "✅ 初始化 Go 项目:$(project)"; \
go mod init $(project); \
go mod tidy; \
fi
mirror: pull
docker build -t $(MIRROR_IMAGE) -f deploy/docker/Dockerfile .
pull:
git reset --hard HEAD
git pull
release-mirror: mirror
docker push $(MIRROR_IMAGE)
rebuild: pull
docker build -t $(IMAGE) -f deploy/docker/Dockerfile .
test:
mkdir -p artifacts/report/coverage
go test -v -cover -coverprofile c.out.tmp ./...
cat c.out.tmp | grep -v "_mock.go" > c.out
go tool cover -html=c.out -o artifacts/report/coverage/index.html
update-dep: update-mod fix-dep
up:
docker-compose build --force-rm --no-cache
docker-compose up
update-mod:
# type your dep