-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskfile.yml
More file actions
354 lines (317 loc) · 11.1 KB
/
Copy pathTaskfile.yml
File metadata and controls
354 lines (317 loc) · 11.1 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
version: '3'
vars:
APP_NAME: "kubegui"
BIN_DIR: ".bin"
VITE_PORT: '{{.WAILS_VITE_PORT | default 9245}}'
LOG_LEVEL: '{{.LOG_LEVEL | default "info"}}'
env:
GOEXPERIMENT: jsonv2
tasks:
build:
summary: Builds the application
cmds:
- task: build:windows:dev
- task: build:windows:debug
- task: build:windows:prod
- task: build:linux
- task: build:darwin
- task: build:mac:dev
- task: build:mac:prod
- task: release
- task: release:mac:prod
# To run -> version=X.Y.z wails3 task release
release:
summary: Release
env:
version: '{{.version}}'
cmds:
- |
echo "Release version - {{.version}}!"
jq ".fixed.file_version = \"{{.version}}\"" build/info.json > build/info_new.json && mv build/info_new.json build/info.json
jq ".info.\"0000\".ProductVersion = \"{{.version}}\"" build/info.json > build/info_new.json && mv build/info_new.json build/info.json
jq ".version = \"{{.version}}\"" wails.json > wails_new.json && mv wails_new.json wails.json
jq ".Info.productVersion = \"{{.version}}\"" wails.json > wails_new.json && mv wails_new.json wails.json
yq e ".info.version = \"{{.version}}\"" -i build/win-dev.yml
yq e ".info.version = \"{{.version}}\"" -i build/win-dev-backend.yml
yq e ".info.version = \"{{.version}}\"" -i build/mac-dev.yml
node -e "const fs=require('fs');let c=fs.readFileSync('build/Info.plist','utf8');['CFBundleVersion','CFBundleShortVersionString'].forEach(k=>{c=c.replace(new RegExp('(<key>'+k+'</key>[^<]*<string>)[^<]*(</string>)'),(_,p1,p2)=>p1+'{{.version}}'+p2);});fs.writeFileSync('build/Info.plist',c);"
node -e "const fs=require('fs');let c=fs.readFileSync('build/Info.dev.plist','utf8');['CFBundleVersion','CFBundleShortVersionString'].forEach(k=>{c=c.replace(new RegExp('(<key>'+k+'</key>[^<]*<string>)[^<]*(</string>)'),(_,p1,p2)=>p1+'{{.version}}'+p2);});fs.writeFileSync('build/Info.dev.plist',c);"
python3 -c "import re; from pathlib import Path; p=Path('./web/index.html'); p.write_text(re.sub(r'(<span class=\"text-xs release-version\">)[^<]*(</span>)', r'\1(v{{.version}})\2', p.read_text()))"
# Windows
build:windows:dev:
summary: Builds DEV application for Windows
# deps:
# - task: go:mod:tidy
# - task: generate:syso
# vars:
# ARCH: '{{.ARCH}}'
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}}.exe -gcflags=all="-l" -ldflags="-X 'main.ENV=DEV'" ./bin/desktop
env:
GOOS: windows
CGO_ENABLED: 0
GOARCH: '{{.ARCH | default ARCH}}'
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:windows:debug:
summary: Builds DEV-DEBUG application for Windows
deps:
- task: go:mod:tidy
- task: generate:icons
- task: generate:syso
vars:
ARCH: '{{.ARCH}}'
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}}.exe -gcflags=all="-l" ./bin/desktop
env:
GOOS: windows
CGO_ENABLED: 0
GOARCH: '{{.ARCH | default ARCH}}'
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:windows:prod:
summary: Builds PRODUCTION application for Windows
deps:
- task: build:frontend
- task: go:mod:tidy
- task: generate:icons
- task: generate:syso
vars:
ARCH: '{{.ARCH}}'
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}}.exe -tags production -trimpath -ldflags="-w -s -H windowsgui" ./bin/desktop
env:
GOOS: windows
CGO_ENABLED: 0
GOARCH: '{{.ARCH | default ARCH}}'
PRODUCTION: '{{.PRODUCTION | default "false"}}'
build:linux:
summary: Builds PRODUCTION application for Linux
deps:
- task: build:frontend
- task: go:mod:tidy
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}} -tags production -trimpath -ldflags="-w -s" ./bin/desktop
env:
GOOS: linux
GOARCH: '{{.ARCH | default "amd64"}}'
CGO_ENABLED: "1"
# MAC
build:mac:dev:
summary: Creates a dev build of the application
deps:
- task: go:mod:tidy
- task: generate:icons
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}} -gcflags=all="-l" -ldflags="-X 'main.ENV=DEV'" ./bin/desktop
env:
GOOS: darwin
GOARCH: amd64
CGO_LDFLAGS: "-framework UniformTypeIdentifiers -mmacosx-version-min=10.13"
CGO_CFLAGS: "-mmacosx-version-min=10.13"
CGO_ENABLED: "1"
build:mac:prod:
summary: Release
deps:
- task: build:frontend
env:
version: '{{.version}}'
cmds:
- task: build:mac:prod:cleanup
- task: build:mac:prod:arm64
- task: build:mac:prod:amd64
- task: build:mac:prod:universal
release:mac:prod:
summary: Release
env:
version: '{{.version}}'
cmds:
- task: build:mac:prod:cleanup
- task: build:mac:prod
- task: build:mac:prod:pack
- task: build:mac:prod:upload
build:mac:prod:cleanup:
summary: Cleanup
cmds:
- rm -f wails.syso
- rm -rf .{{.BIN_DIR}}/*
build:mac:prod:arm64:
summary: Creates a production build for ARM64
deps:
- task: go:mod:tidy
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}}-arm64 -tags production -trimpath -ldflags="-w -s" ./bin/desktop
env:
GOOS: darwin
GOARCH: arm64
CGO_LDFLAGS: "-framework UniformTypeIdentifiers -mmacosx-version-min=10.13"
CGO_CFLAGS: "-mmacosx-version-min=10.13"
CGO_ENABLED: "1"
build:mac:prod:amd64:
summary: Creates a production build of the application for AMD64
deps:
- task: go:mod:tidy
cmds:
- go build -v -o {{.BIN_DIR}}/{{.APP_NAME}}-amd64 -tags production -trimpath -ldflags="-w -s" ./bin/desktop
env:
GOOS: darwin
GOARCH: amd64
CGO_LDFLAGS: "-framework UniformTypeIdentifiers -mmacosx-version-min=10.13"
CGO_CFLAGS: "-mmacosx-version-min=10.13"
CGO_ENABLED: "1"
build:mac:prod:universal:
summary: Create Universal Binary
cmds:
- lipo -create -output {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}-arm64 {{.BIN_DIR}}/{{.APP_NAME}}-amd64
- chmod +x {{.BIN_DIR}}/{{.APP_NAME}}
- mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/{MacOS,Resources}
- cp build/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources
- cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS
- cp build/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents
# build:mac:prod:sign:
# summary: Bin sign
# cmds:
# - security unlock-keychain -p 'xxx' /Users/xxx/Library/Keychains/xxx
# - codesign --deep --force --options runtime --sign "xxx" {{.BIN_DIR}}/{{.APP_NAME}}.app
# - codesign --verify --deep --strict --verbose=2 {{.BIN_DIR}}/{{.APP_NAME}}.app
build:mac:prod:pack:
summary: ZIP
cmds:
- ditto -c -k --keepParent {{.BIN_DIR}}/{{.APP_NAME}}.app {{.BIN_DIR}}/{{.APP_NAME}}-macos.zip
# build:mac:prod:notarize:
# summary: Notarization
# cmds:
# - xcrun notarytool submit {{.BIN_DIR}}/{{.APP_NAME}}-macos.zip --apple-id "xxx" --team-id "xxx" --password "xxx" --wait
# build:mac:prod:staple:
# summary: Staple
# cmds:
# - xcrun stapler staple {{.BIN_DIR}}/{{.APP_NAME}}.app
build:mac:prod:upload:
summary: Upload to github
cmds:
- gh release create "v{{.version}}" --title "Release v{{.version}}" --notes "..." -R gerbil/kubegui || true
- gh release upload v{{.version}} {{.BIN_DIR}}/{{.APP_NAME}}-macos.zip --clobber -R gerbil/kubegui
# MISC
generate:syso:
summary: Generates Windows `.syso` file
dir: build
cmds:
- wails3 generate syso -arch {{.ARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso
vars:
ARCH: '{{.ARCH | default ARCH}}'
create:nsis:installer:
summary: Creates an NSIS installer
label: "NSIS Installer ({{.ARCH}})"
dir: build/nsis
sources:
- "{{.ROOT_DIR}}\\{{.BIN_DIR}}\\{{.APP_NAME}}.exe"
generates:
- "{{.ROOT_DIR}}\\{{.BIN_DIR}}\\{{.APP_NAME}}-{{.ARCH}}-installer.exe"
deps:
- task: build:windows
vars:
PRODUCTION: "true"
ARCH: '{{.ARCH}}'
cmds:
- makensis -DARG_WAILS_'{{.ARG_FLAG}}'_BINARY="{{.ROOT_DIR}}\{{.BIN_DIR}}\{{.APP_NAME}}.exe" project.nsi
vars:
ARCH: '{{.ARCH | default ARCH}}'
ARG_FLAG: '{{if eq .ARCH "amd64"}}AMD64{{else}}ARM64{{end}}'
generate:icons:
summary: Generates Windows `.ico` and Mac `.icns` files from an image
dir: build
sources:
- "appicon.png"
generates:
- "icons.icns"
- "icons.ico"
cmds:
# Generates both .ico and .icns files
- wails3 generate icons -input appicon.png -windowsfilename icon.ico -macfilename icons.icns
generate:bindings:
summary: Generates bindings for the frontend
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "ui/bindings/**/*"
cmds:
# For a complete list of options, run `wails3 generate bindings -help`
- wails3 generate bindings ./... -ts -d ui/bindings
install:frontend:deps:
summary: Install frontend dependencies
dir: ui
preconditions:
- sh: npm version
msg: "npm is required to run frontend dev server"
cmds:
- npm install
- npm run build
dev:bootstrap:
summary: Prepare generated bindings and frontend assets for dev
cmds:
- task: generate:bindings
- task: install:frontend:deps
build:frontend:
summary: Builds the frontend for production
dir: ui
sources:
- "src/**/*"
- "tsconfig.json"
- "vite.config.ts"
- "package.json"
- "package-lock.json"
generates:
- "dist/**/*"
cmds:
- npm install
- npm ci
- npm audit fix
# Ensure the rolldown native binding is present (optional dep skipped when Node engine version is too old)
- node -e "if(process.platform==='win32'){require('child_process').execSync('npm install @rolldown/binding-win32-x64-msvc --no-save --ignore-engines',{stdio:'inherit'})}"
- npm run build
go:mod:tidy:
summary: Runs `go mod tidy`
internal: true
generates:
- go.sum
sources:
- go.mod
cmds:
- go mod tidy
# RUN
run:
summary: Runs the application
cmds:
- task: run:{{OS}}
run:windows:
env:
APPDATA: '{{.APPDATA | default (env "APPDATA")}}'
USERPROFILE: '{{.USERPROFILE | default (env "USERPROFILE")}}'
cmds:
- 'cmd.exe /C "{{.BIN_DIR}}\\{{.APP_NAME}}.exe"'
run:linux:
cmds:
- '{{.BIN_DIR}}/{{.APP_NAME}}'
run:darwin:
cmds:
- '{{.BIN_DIR}}/{{.APP_NAME}}'
# DEV
dev:frontend:
summary: Runs the frontend in development mode
dir: ui
cmds:
- npm run dev -- --host --port {{.VITE_PORT}}
dev:backend:
summary: Runs backend app only (expects frontend dev server already running)
env:
LOG_LEVEL: '{{.LOG_LEVEL}}'
cmds:
- wails3 dev -config ./build/win-dev-backend.yml -port {{.VITE_PORT}}
dev:all:
summary: Runs frontend and backend together
cmds:
- wails3 dev -config ./build/win-dev.yml -port {{.VITE_PORT}}
dev:reload:
summary: Reloads the application
cmds:
- task: run