-
Notifications
You must be signed in to change notification settings - Fork 53
/
Taskfile.yml
132 lines (117 loc) · 3.07 KB
/
Taskfile.yml
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
# https://taskfile.dev
version: '3'
env:
GOPROXY: 'https://goproxy.cn,direct'
GOSUMDB: sum.golang.google.cn
GO_VERSION: $(go version)
BUILD_VERSION: $(cat VERSION || echo "0.0.1")
BUILD_TIME: $(date "+%Y%m%d%H%M")
GIT_COMMIT: $(git rev-parse --short HEAD || echo "abcdefgh")
ROOT_DIR: $(pwd)
BUILD_DIR: $(pwd)/_output
BIN_DIR: $(pwd)/bin
CLIENT_BIN_DIR: client/bin
CLIENT_OUT_DIR: client/out
LDFLAGS: "-w -s \
-X 'main.AppVersion={{.BUILD_VERSION}}' \
-X 'main.GoVersion={{.GO_VERSION}}' \
-X 'main.BuildTime={{.BUILD_TIME}}' \
-X 'main.BuildTime={{.BUILD_TIME}}' \
-X 'main.GitHash=${GIT_COMMIT}'"
tasks:
fmt:
desc: format code
cmds:
- gci write --skip-generated --custom-order -s standard -s default -s "prefix(github.com/easysoft/zentaoatf)" -s blank -s dot -s alias .
- gofmt -s -w .
- goimports -w .
clean:
desc: clean
cmds:
- rm -rf res/res.go
install:
desc: install dep tools
run: once
cmds:
- go install github.com/kevinburke/go-bindata/v4/...@latest
status:
- command -v go-bindata
compile_ui:
desc: compile client ui
run: once
dir: ui
cmds:
- yarn install
- yarn build
prepare:
desc: start prepare res
# run: once
deps:
- install
# - compile_ui
cmds:
- go-bindata -o=res/res.go -pkg=res res/...
status:
- test -f res/res.go
build_server:
desc: Build the server
run: once
cmds:
- GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags "{{.LDFLAGS}}" -o {{.BUILD_DIR}}/{{.GOOS}}/{{.GOARCH}}/ztf-server{{if eq .GOOS "windows"}}.exe{{end}} cmd/server/main.go
status:
- test -f {{.BUILD_DIR}}/{{.GOOS}}/{{.GOARCH}}/ztf-server{{if eq .GOOS "windows"}}.exe{{end}}
package_gui_client:
desc: start package gui
run: once
dir: client
cmds:
- npm install
- npm run package-{{.GOOS}}-{{.GOARCH}}
build_cli:
desc: Build the CLI
# run: once
cmds:
- GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags "{{.LDFLAGS}}" -o /tmp/ztf{{if eq .GOOS "windows"}}.exe{{end}} cmd/command/main.go
# status:
# - test -f {{.BUILD_DIR}}/{{.GOOS}}/{{.GOARCH}}/ztf{{if eq .GOOS "windows"}}.exe{{end}}
zip:
desc: zip
run: once
dir: "{{.BUILD_DIR}}/{{.GOOS}}/{{.GOARCH}}"
cmds:
- cp -a ../../../demo .
- cp -a ../../../client/out/ztf-{{.GOOS}}-{{.GOARCH}} gui
dev:
desc: dev
cmds:
- task: fmt
- make prepare
- make compile_command_linux
default:
cmds:
# - task: prepare
# - task: build_server
# vars: {
# GOOS: darwin,
# GOARCH: arm64
# }
# - task: package_gui_client
# vars: {
# GOOS: darwin,
# GOARCH: arm64
# }
# - task: build_cli
# vars: {
# GOOS: darwin,
# GOARCH: arm64
# }
- task: build_cli
vars: {
GOOS: linux,
GOARCH: amd64
}
- task: build_cli
vars: {
GOOS: windows,
GOARCH: amd64
}