-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
79 lines (77 loc) · 2.25 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
SHELL := /bin/bash
BASEDIR = $(shell pwd)
APP_NAME=dingtalk
APP_VERSION=1.5.0
IMAGE_NAME="catchzeng/${APP_NAME}:${APP_VERSION}"
IMAGE_LATEST="catchzeng/${APP_NAME}:latest"
all: mod fmt imports lint test
first:
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
fmt:
gofmt -w .
mod:
go mod tidy
imports:
goimports -w .
lint:
golangci-lint run
.PHONY: test
test:
sh scripts/test.sh
test-sonar:
go test -gcflags=-l -coverpkg=./... -coverprofile=coverage.data ./...
mock:
sh scripts/mock.sh
.PHONY: build
build:
rm -f dingtalk
go build -o dingtalk main.go
build-darwin-amd64:
rm -f dingtalk dingtalk-darwin-amd64.zip
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o dingtalk main.go
zip dingtalk-darwin-amd64.zip dingtalk
build-darwin-arm64:
rm -f dingtalk dingtalk-darwin-arm64.zip
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o dingtalk main.go
zip dingtalk-darwin-arm64.zip dingtalk
build-linux:
rm -f dingtalk dingtalk-linux-amd64.zip
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dingtalk main.go
zip dingtalk-linux-amd64.zip dingtalk
build-win:
rm -f dingtalk.exe dingtalk-windows-amd64.zip
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dingtalk.exe main.go
zip dingtalk-windows-amd64.zip dingtalk.exe
build-win32:
rm -f dingtalk.exe dingtalk-windows-386.zip
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o dingtalk.exe main.go
zip dingtalk-windows-386.zip dingtalk.exe
build-release:
make build-darwin-amd64
make build-darwin-arm64
make build-linux
make build-win
make build-win32
rm -f dingtalk dingtalk.exe
build-docker:
sh build/package/build.sh ${IMAGE_NAME}
push-docker:
docker tag ${IMAGE_NAME} ${IMAGE_LATEST};
docker push ${IMAGE_NAME};
docker push ${IMAGE_LATEST};
help:
@echo "first - first time"
@echo "fmt - go format"
@echo "mod - go mod tidy"
@echo "imports - go imports"
@echo "lint - run golangci-lint"
@echo "test - unit test"
@echo "mock - mockgen"
@echo "build - build binary"
@echo "build-mac - build mac binary"
@echo "build-linux - build linux amd64 binary"
@echo "build-win - build win amd64 binary"
@echo "build-win32 - build win 386 binary"
@echo "build-docker - build docker image"
@echo "push-docker - push docker image to docker hub"