-
Notifications
You must be signed in to change notification settings - Fork 112
/
Taskfile.yml
272 lines (248 loc) · 9.73 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
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
# Copyright 2024, Command Line Inc.
# SPDX-License-Identifier: Apache-2.0
version: "3"
vars:
APP_NAME: "Wave"
BIN_DIR: "bin"
VERSION:
sh: node version.cjs
RM: '{{if eq OS "windows"}}cmd --% /c del /S{{else}}rm {{end}}'
RMRF: '{{if eq OS "windows"}}powershell Remove-Item -Force -Recurse{{else}}rm -rf{{end}}'
DATE: '{{if eq OS "windows"}}powershell Get-Date -UFormat{{else}}date{{end}}'
ARTIFACTS_BUCKET: waveterm-github-artifacts/staging-w2
RELEASES_BUCKET: dl.waveterm.dev/releases-w2
WINGET_PACKAGE: CommandLine.Wave
tasks:
electron:dev:
desc: Run the Electron application via the Vite dev server (enables hot reloading).
cmd: yarn dev
deps:
- yarn
- build:backend
env:
WCLOUD_ENDPOINT: "https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev"
WCLOUD_WS_ENDPOINT: "wss://5lfzlg5crl.execute-api.us-west-2.amazonaws.com/dev/"
electron:start:
desc: Run the Electron application directly.
cmd: yarn start
deps:
- yarn
- build:backend
storybook:
desc: Start the Storybook server.
cmd: yarn storybook
package:
desc: Package the application for the current platform.
cmds:
- cmd: '{{.RMRF}} "make"'
ignore_error: true
- yarn build:prod && yarn electron-builder -c electron-builder.config.cjs -p never
deps:
- yarn
- build:backend
build:backend:
desc: Build the wavesrv and wsh components.
cmds:
- task: build:server
- task: build:wsh
build:server:
desc: Build the wavesrv component.
deps:
- generate
- build:server:linux
- build:server:macos
- build:server:windows
build:server:macos:
desc: Build the wavesrv component for macOS (Darwin) platforms (generates artifacts for both arm64 and amd64).
status:
- exit {{if eq OS "darwin"}}1{{else}}0{{end}}
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
ignore_error: true
- task: build:server:internal
vars:
ARCHS: arm64,amd64
build:server:windows:
desc: Build the wavesrv component for Windows platforms (only generates artifacts for the current architecture).
status:
- exit {{if eq OS "windows"}}1{{else}}0{{end}}
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
ignore_error: true
- task: build:server:internal
vars:
ARCHS:
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
build:server:linux:
desc: Build the wavesrv component for Linux platforms (only generates artifacts for the current architecture).
status:
- exit {{if eq OS "linux"}}1{{else}}0{{end}}
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
ignore_error: true
- task: build:server:internal
vars:
ARCHS:
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
GO_ENV_VARS:
sh: echo "{{if eq "amd64" ARCH}}CC=\"zig cc -target x86_64-linux-gnu.2.28\"{{end}}"
build:server:internal:
requires:
vars:
- ARCHS
cmd:
cmd: CGO_ENABLED=1 GOARCH={{.GOARCH}} {{.GO_ENV_VARS}} go build -tags "osusergo,sqlite_omit_load_extension" -ldflags "{{.GO_LDFLAGS}} -X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.WaveVersion={{.VERSION}}" -o dist/bin/wavesrv.{{if eq .GOARCH "amd64"}}x64{{else}}{{.GOARCH}}{{end}}{{exeExt}} cmd/server/main-server.go
for:
var: ARCHS
split: ","
as: GOARCH
sources:
- "cmd/server/*.go"
- "pkg/**/*.go"
generates:
- dist/bin/wavesrv.*{{exeExt}}
deps:
- go:mod:tidy
internal: true
build:wsh:
desc: Build the wsh component for all possible targets.
cmds:
- cmd: "{{.RM}} dist/bin/wsh*"
ignore_error: true
- task: build:wsh:internal
vars:
GOOS: darwin
GOARCH: arm64
- task: build:wsh:internal
vars:
GOOS: darwin
GOARCH: amd64
- task: build:wsh:internal
vars:
GOOS: linux
GOARCH: arm64
- task: build:wsh:internal
vars:
GOOS: linux
GOARCH: amd64
- task: build:wsh:internal
vars:
GOOS: windows
GOARCH: amd64
- task: build:wsh:internal
vars:
GOOS: windows
GOARCH: arm64
deps:
- generate
dev:installwsh:
desc: quick shortcut to rebuild wsh and install for macos arm64
requires:
vars:
- VERSION
cmds:
- task: build:wsh:internal
vars:
GOOS: darwin
GOARCH: arm64
- cp dist/bin/wsh-{{.VERSION}}-darwin.arm64 ~/Library/Application\ Support/waveterm-dev/bin/wsh
build:wsh:internal:
vars:
EXT:
sh: echo {{if eq .GOOS "windows"}}.exe{{end}}
NORMALIZEDARCH:
sh: echo {{if eq .GOARCH "amd64"}}x64{{else}}{{.GOARCH}}{{end}}
requires:
vars:
- GOOS
- GOARCH
- VERSION
sources:
- "cmd/wsh/**/*.go"
- "pkg/**/*.go"
generates:
- dist/bin/wsh-{{.VERSION}}-{{.GOOS}}.{{.NORMALIZEDARCH}}{{.EXT}}
cmd: (CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags="-s -w -X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.WaveVersion={{.VERSION}}" -o dist/bin/wsh-{{.VERSION}}-{{.GOOS}}.{{.NORMALIZEDARCH}}{{.EXT}} cmd/wsh/main-wsh.go)
deps:
- go:mod:tidy
internal: true
generate:
desc: Generate Typescript bindings for the Go backend.
cmds:
- go run cmd/generatets/main-generatets.go
- go run cmd/generatego/main-generatego.go
sources:
- "cmd/generatego/*.go"
- "cmd/generatets/*.go"
- "pkg/**/*.go"
# don't add generates key (otherwise will always execute)
version:
desc: Get the current package version, or bump version if args are present. To pass args to `version.cjs`, add them after `--`. See `version.cjs` for usage definitions for the arguments.
cmd: node version.cjs {{.CLI_ARGS}}
artifacts:upload:
desc: Uploads build artifacts to the staging bucket in S3. To add additional AWS CLI arguments, add them after `--`.
vars:
ORIGIN: "make/"
DESTINATION: "{{.ARTIFACTS_BUCKET}}/{{.VERSION}}"
cmd: aws s3 cp {{.ORIGIN}}/ s3://{{.DESTINATION}}/ --recursive --exclude "*/*" --exclude "builder-*.yml" {{.CLI_ARGS}}
artifacts:download:*:
desc: Downloads the specified artifacts version from the staging bucket. To add additional AWS CLI arguments, add them after `--`.
vars:
DL_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
ORIGIN: "{{.ARTIFACTS_BUCKET}}/{{.DL_VERSION}}"
DESTINATION: "artifacts/{{.DL_VERSION}}"
cmds:
- '{{.RMRF}} "{{.DESTINATION}}"'
- aws s3 cp s3://{{.ORIGIN}}/ {{.DESTINATION}}/ --recursive {{.CLI_ARGS}}
artifacts:publish:*:
desc: Publishes the specified artifacts version from the staging bucket to the releases bucket. To add additional AWS CLI arguments, add them after `--`.
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
ORIGIN: "{{.ARTIFACTS_BUCKET}}/{{.UP_VERSION}}"
DESTINATION: "{{.RELEASES_BUCKET}}"
cmd: |
OUTPUT=$(aws s3 cp s3://{{.ORIGIN}}/ s3://{{.DESTINATION}}/ --recursive {{.CLI_ARGS}})
for line in $OUTPUT; do
PREFIX=${line%%{{.DESTINATION}}*}
SUFFIX=${line:${#PREFIX}}
if [[ -n "$SUFFIX" ]]; then
echo "https://$SUFFIX"
fi
done
artifacts:snap:publish:*:
desc: Publishes the specified artifacts version to Snapcraft.
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
CHANNEL: '{{if contains "beta" .UP_VERSION}}beta{{else}}beta,stable{{end}}'
cmd: |
echo "Releasing to channels: [{{.CHANNEL}}]"
snapcraft upload --release={{.CHANNEL}} waveterm_{{.UP_VERSION}}_arm64.snap
snapcraft upload --release={{.CHANNEL}} waveterm_{{.UP_VERSION}}_amd64.snap
artifacts:winget:publish:*:
desc: Submits a version bump request to WinGet for the latest release.
status:
- exit {{if contains "beta" .UP_VERSION}}0{{else}}1{{end}}
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
cmd: |
wingetcreate update {{.WINGET_PACKAGE}} -s -v {{.UP_VERSION}} -u "https://{{.RELEASES_BUCKET}}/{{.APP_NAME}}-win32-x64-{{.UP_VERSION}}.msi" -t $env:GITHUB_TOKEN
yarn:
desc: Runs `yarn`
internal: true
generates:
- node_modules/**/*
- yarn.lock
- .yarn/*
sources:
- yarn.lock
- package.json
- .yarnrc.yml
cmd: yarn
go:mod:tidy:
desc: Runs `go mod tidy`
internal: true
generates:
- go.sum
sources:
- go.mod
cmd: go mod tidy