-
Notifications
You must be signed in to change notification settings - Fork 50
/
win64.yaml
200 lines (181 loc) · 7.02 KB
/
win64.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
version: '3'
vars:
GOOS: $(go env GOOS)
GOARCH: $(go env GOARCH)
BIN_DIR: $(pwd)/bin
CLIENT_OUT_DIR: client/out
CLIENT_BIN_DIR: client/bin
CLIENT_OUT_DIR_EXECUTABLE: "{{.CLIENT_OUT_DIR}}/executable/"
CLIENT_OUT_DIR_UPGRADE: "{{.CLIENT_OUT_DIR}}/upgrade/"
QINIU_DIR: .release/qiniu
VERSION:
sh: head -n 1 VERSION
PROJECT: zd
GO_VERSION:
sh: go version
BUILD_TIME:
sh: git show -s --format=%cd
GIT_HASH:
sh: git show -s --format=%H
LDFLAGS: "-w -s \
-X 'main.AppVersion={{.VERSION}}' \
-X 'main.BuildTime={{.BUILD_TIME}}' \
-X 'main.GoVersion={{.GO_VERSION}}' \
-X 'main.GitHash={{.GIT_HASH}}'"
tasks:
default:
cmds:
- task: clear
- task: build_ui
- task: prepare_build
- task: compile_all
- task: copy_files
- task: package
package:
desc: package
vars:
PLATFORMS:
sh: ls {{.CLIENT_OUT_DIR_EXECUTABLE}}
cmds:
- find . -name .DS_Store -print0 | xargs -0 rm -f
- for platform in {{.PLATFORMS}}; do mkdir -p {{.QINIU_DIST_DIR}}/$${platform}; done
- task: package_win64
package_win64:
desc: package win64
dir: "{{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/"
cmds:
- zip -ry {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64.zip .
- md5sum {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64.zip > {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64.zip.md5
- cp -r ../../../ui ./
- zip -ry {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64-upgrade.zip .
- md5sum {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64-upgrade.zip > {{.QINIU_DIST_DIR}}/win64/{{.PROJECT}}-win64-upgrade.zip.md5
copy_files:
desc: copy files
cmds:
- cp -r .zd.conf {{.BIN_DIR}}
- cp -r data {{.BIN_DIR}}
- cp -r yaml {{.BIN_DIR}}
- cp -r users {{.BIN_DIR}}
- cp -r demo {{.BIN_DIR}}
- cp -r runtime {{.BIN_DIR}}
- rm -rf {{.BIN_DIR}}/demo/out
- rm -rf {{.BIN_DIR}}/yaml/article/chinese/slang/out
- rm -rf {{.BIN_DIR}}/runtime/protobuf/out
- mkdir -p {{.BIN_DIR}}/tmp/cache
- sqlite3 tmp/cache/.data.db ".backup '{{.BIN_DIR}}/tmp/cache/.data.db'"
- sqlite3 '{{.BIN_DIR}}/tmp/cache/.data.db' ".read 'xdoc/clear-data.txt'"
- task: copy_files_win64
# - |
# for platform in {{.PLATFORMS}};do \
# cp -r .zd.conf "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/data "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/runtime "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/yaml "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/users "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/demo "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp -r bin/tmp "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}"; \
# cp {{.BIN_DIR}}/$${platform}/{{.PROJECT}}.exe "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}" || true; \
# cp {{.BIN_DIR}}/$${platform}/{{.PROJECT}} "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}" || true; \
# cp {{.BIN_DIR}}/$${platform}/{{.PROJECT}}-gui.exe "{{.CLIENT_OUT_DIR_EXECUTABLE}}$${platform}" || true; \
# done
# - rm -rf {{.BIN_OUT}}/linux/runtime/php
# - rm -rf {{.BIN_OUT}}/linux/runtime/protobuf/bin/mac
# - rm -rf {{.BIN_OUT}}/linux/runtime/protobuf/bin/win*
# - rm -rf {{.BIN_OUT}}/darwin/runtime/php
# - rm -rf {{.BIN_OUT}}/darwin/runtime/protobuf/bin/linux
# - rm -rf {{.BIN_OUT}}/darwin/runtime/protobuf/bin/win*
# - rm -rf {{.BIN_OUT}}/win64/runtime/protobuf/bin/linux
# - rm -rf {{.BIN_OUT}}/win64/runtime/protobuf/bin/mac
copy_files_win64:
desc: copy files win64
cmds:
- cp -r .zd.conf {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/data {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/runtime {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/yaml {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/users {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/demo {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp -r bin/tmp {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp {{.BIN_DIR}}/win64/{{.PROJECT}}.exe {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
- cp {{.BIN_DIR}}/win64/{{.PROJECT}}-gui.exe {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/
compile_all:
desc: compile all
cmds:
- task: compile_win64
compile_win64:
desc: compile win64
cmds:
- task: compile_launcher_win64
- task: compile_server_win64
- task: package_gui_win64_client
- task: compile_command_win64
compile_command_win64:
desc: compile command win64
cmds:
- GOOS=windows GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o {{.BIN_DIR}}/win64/{{.PROJECT}}.exe cmd/command/main.go
package_gui_win64_client:
desc: package gui win64 client
cmds:
- rm -rf {{.CLIENT_BIN_DIR}}/*
- mkdir -p {{.CLIENT_BIN_DIR}}/win64
- cp -rf {{.BIN_DIR}}/win64/server.exe {{.CLIENT_BIN_DIR}}/win64/server.exe
- task: package_win64_client
- rm -rf {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64
- mkdir -p {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64
- cp -rf {{.CLIENT_BIN_DIR}}/win64 {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64
- mv {{.CLIENT_OUT_DIR}}/{{.PROJECT}}-win32-x64 {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/gui
package_win64_client:
desc: package win64 client
dir: client
cmds:
- npm install
- npm run package-win64
compile_server_win64:
desc: compile server win64
cmds:
- GOOS=windows GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o {{.BIN_DIR}}/win64/server.exe cmd/server/main.go
- rm -rf {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64
- mkdir -p {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64
- cp {{.BIN_DIR}}/win64/server.exe {{.CLIENT_OUT_DIR_EXECUTABLE}}/win64/server.exe
compile_launcher_win64_dep:
desc: compile launcher win64 dep
cmds:
- rsrc -arch amd64 -manifest xdoc/main.manifest -ico xdoc/favicon.ico -o cmd/launcher/main.syso
compile_launcher_win64:
desc: compile launcher win64
deps:
- task: compile_launcher_win64_dep
dir: cmd/launcher
cmds:
- GOOS=windows GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o ../../{{.BIN_DIR}}/win64/{{.PROJECT}}-gui.exe
prepare_build:
desc: prepare build
cmds:
- task: clear
- task: update_version_in_config
- task: prepare_res
prepare_res:
desc: prepare res
cmds:
- cp res/zh/sample.yaml demo/default.yaml
update_version_in_config:
desc: update version in config
cmds:
- mkdir -p {{.QINIU_DIR}}/{{.PROJECT}}
- sed -i "s/Version.*/Version = {{.VERSION}}/" .zd.conf
- echo '{"version":"{{.VERSION}}"}' > {{.QINIU_DIR}}/{{.PROJECT}}/version.json
- echo '{{.VERSION}}' > {{.QINIU_DIR}}/{{.PROJECT}}/version.txt
build_ui:
desc: build ui
dir: ui
cmds:
- yarn install
- yarn build --dest ../client/ui
clear:
desc: clear
cmds:
- rm -rf {{.BIN_DIR}}
- rm -rf {{.CLIENT_OUT_DIR}}
status:
- test -d {{.BIN_DIR}}
- test -d {{.CLIENT_OUT_DIR}}