-
Notifications
You must be signed in to change notification settings - Fork 49
501 lines (488 loc) · 21.8 KB
/
release-vscode.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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# stolen from https://github.com/nvarner/tinymist/blob/master/.github/workflows/release.yml
name: tinymist::ci
on:
push:
branches:
- main
- 'nightly/*'
tags:
- "*"
pull_request:
types: [opened, synchronize]
branches:
- main
- 'nightly/*'
workflow_dispatch:
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
jobs:
pre_build:
permissions:
actions: write
contents: read
name: Duplicate Actions Detection
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: "true"
checks:
name: Check clippy, formatting, and documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install deps
run: yarn install
- name: Check and build typst-preview
run: |
yarn build:preview
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features
- run: cargo fmt --check --all
- run: cargo doc --workspace --no-deps
# region: check-min-version
min-version:
name: Check minimum Rust version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Check MSRV
run: yarn check-msrv
- uses: dtolnay/[email protected]
- uses: Swatinem/rust-cache@v2
- run: cargo check --workspace
# end-region: check-min-version
build:
strategy:
matrix:
include:
- os: windows-latest
rust-target: x86_64-pc-windows-msvc
platform: win32
arch: x64
regular_build: 'true'
- os: windows-latest
rust-target: aarch64-pc-windows-msvc
platform: win32
arch: arm64
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
platform: linux
arch: x64
regular_build: 'true'
- os: ubuntu-20.04
rust-target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
- os: ubuntu-20.04
rust-target: arm-unknown-linux-gnueabihf
platform: linux
arch: armhf
- os: macos-13
rust-target: x86_64-apple-darwin
platform: darwin
arch: x64
- os: macos-13
rust-target: aarch64-apple-darwin
platform: darwin
arch: arm64
regular_build: 'true'
name: build (${{ matrix.platform }}-${{ matrix.arch }})
runs-on: ${{ matrix.os }}
env:
target: ${{ matrix.platform }}-${{ matrix.arch }}
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
isTest: ${{ matrix.rust-target == 'x86_64-unknown-linux-gnu' || matrix.rust-target == 'x86_64-pc-windows-msvc' }}
isUniversal: ${{ matrix.rust-target == 'x86_64-unknown-linux-gnu' }}
steps:
- name: "Print Env"
run: |
echo "Running on ${{ matrix.os }}"
echo "Target: ${{ env.target }}"
echo "Is Release: ${{ fromJson(env.isRelease) }}"
echo "Is Nightly: ${{ fromJson(env.isNightly) }}"
echo "Is Test: ${{ fromJson(env.isTest) }}"
echo "Is Universal (No Server): ${{ fromJson(env.isUniversal) }}"
- uses: actions/checkout@v4
with:
submodules: recursive
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Install deps
run: yarn install
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Build typst-preview vscode extension
run: |
yarn
yarn run compile
working-directory: ./contrib/typst-preview/editors/vscode
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Build tinymist vscode extension
run: |
yarn
yarn run compile
working-directory: ./editors/vscode
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust-target }}
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Install llvm
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
sudo apt-get update
sudo apt-get install llvm
- name: Install AArch64 target toolchain
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
- name: Install ARM target toolchain
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Run rust-cache
uses: Swatinem/rust-cache@v2
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
- name: Build tinymist binary
shell: pwsh
run: |
cargo build --profile=gh-release -p tinymist --target ${{ matrix.rust-target }}
if: startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true'
- name: Rename debug symbols for windows
if: matrix.platform == 'win32' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
cd target/${{ matrix.rust-target }}/gh-release
cp tinymist.pdb tinymist-${{ env.target }}.pdb
- name: Split debug symbols for linux
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
cd target/${{ matrix.rust-target }}/gh-release
llvm-objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
llvm-objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
- name: Collect debug symbols for mac
if: matrix.platform == 'darwin' && (fromJson(env.isRelease) || fromJson(env.isNightly))
run: |
dsymutil -f "target/${{ matrix.rust-target }}/gh-release/tinymist"
mv "target/${{ matrix.rust-target }}/gh-release/tinymist.dwarf" "target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf"
- name: Copy binary to output directory
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
shell: pwsh
run: |
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "editors/vscode/out/"
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "contrib/typst-preview/editors/vscode/out/"
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "tinymist-${{ env.target }}$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )"
- name: Test tinymist
run: |
cargo test --profile=gh-release --workspace --target ${{ matrix.rust-target }}
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
- name: Upload split debug symbols for windows
if: matrix.platform == 'win32' && (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.pdb
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.pdb
- name: Upload split debug symbols for linux
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.debug
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.debug
compression-level: 0
- name: Upload split debug symbols for mac
if: matrix.platform == 'darwin' && (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.dwarf
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf
- name: Upload binary artifact
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}
path: tinymist-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
- name: Package typst-preview extension
if: fromJson(env.isRelease)
shell: pwsh
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
working-directory: ./contrib/typst-preview/editors/vscode
- name: Package tinymist extension
if: fromJson(env.isRelease)
shell: pwsh
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
working-directory: ./editors/vscode
- name: Package typst-preview extension (Nightly)
if: fromJson(env.isNightly)
shell: pwsh
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
working-directory: ./contrib/typst-preview/editors/vscode
- name: Package tinymist extension (Nightly)
if: fromJson(env.isNightly)
shell: pwsh
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
working-directory: ./editors/vscode
- name: Test tinymist extension
uses: coactions/setup-xvfb@v1
with:
run: yarn test
working-directory: ./editors/vscode
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
- name: Upload typst-preview VSIX artifact
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: typst-preview-${{ env.target }}.vsix
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
- name: Upload VSIX artifact
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.vsix
path: editors/vscode/tinymist-${{ env.target }}.vsix
# The universal target doesn't bundle the binary. Users of that must install
# tinymist by themselves.
- name: Remove server binary
if: fromJson(env.isUniversal)
run: rm "editors/vscode/out/tinymist"
- name: Package extension (Universal)
if: fromJson(env.isRelease) && fromJson(env.isUniversal)
run: yarn run package -- -o tinymist-universal.vsix
working-directory: ./editors/vscode
- name: Package extension (Universal, Nightly)
if: fromJson(env.isNightly) && fromJson(env.isUniversal)
run: yarn run package -- -o tinymist-universal.vsix --pre-release
working-directory: ./editors/vscode
- name: Upload tinymist VSIX artifact (Universal)
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isUniversal)
uses: actions/upload-artifact@v4
with:
name: tinymist-universal.vsix
path: editors/vscode/tinymist-universal.vsix
- name: Upload Tinymist E2E Test Snapshot
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-snapshot-${{ env.target }}
path: target/e2e
- name: Upload Tinymist Testing log
if: always()
uses: actions/upload-artifact@v4
with:
name: tinymist-lsp-tests.${{ env.target }}.log
path: editors/vscode/e2e-workspaces/simple-docs/tinymist-lsp.log
build_alpine:
name: build (alpine-x64)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
container:
image: rust:alpine
volumes:
- /usr/local/cargo/registry:/usr/local/cargo/registry
env:
target: alpine-x64
RUST_TARGET: x86_64-unknown-linux-musl
RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
steps:
- name: Install dependencies
run: apk add --no-cache git clang lld musl-dev nodejs npm yarn binutils
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run rust-cache
uses: Swatinem/rust-cache@v2
- name: Install deps
run: yarn install
- name: Build typst-preview vscode extension
run: |
yarn
yarn run compile
working-directory: ./contrib/typst-preview/editors/vscode
- name: Build tinymist vscode extension
run: |
yarn
yarn run compile
working-directory: ./editors/vscode
- name: Build tinymist binary
run: |
cargo build --profile=gh-release -p tinymist --target $RUST_TARGET
- name: Split debug symbols
run: |
cd target/$RUST_TARGET/gh-release
objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
- name: Upload split debug symbols
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.debug
path: target/${{ env.RUST_TARGET }}/gh-release/tinymist-${{ env.target }}.debug
- name: Copy binary to output directory
run: |
mkdir -p editors/vscode/out
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "editors/vscode/out/"
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "contrib/typst-preview/editors/vscode/out/"
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "tinymist-${{ env.target }}"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}
path: tinymist-${{ env.target }}
- name: Package typst-preview extension
if: fromJson(env.isRelease)
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
working-directory: ./contrib/typst-preview/editors/vscode
- name: Package extension
if: fromJson(env.isRelease)
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
working-directory: ./editors/vscode
- name: Package typst-preview extension (Nightly)
if: fromJson(env.isNightly)
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
working-directory: ./contrib/typst-preview/editors/vscode
- name: Package extension (Nightly)
if: fromJson(env.isNightly)
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
working-directory: ./editors/vscode
- name: Upload typst-preview VSIX artifact
uses: actions/upload-artifact@v4
with:
name: typst-preview-${{ env.target }}.vsix
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
- name: Upload tinymist VSIX artifact
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.vsix
path: editors/vscode/tinymist-${{ env.target }}.vsix
build_web:
name: build (web)
runs-on: ubuntu-latest
env:
target: web
RUST_TARGET: wasm32-unknown-unknown
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- uses: jetli/[email protected]
with:
version: "v0.13.1"
- name: Run rust-cache
uses: Swatinem/rust-cache@v2
- name: Install deps
run: yarn install
- name: Build tinymist vscode extension
run: |
yarn
yarn run compile:web
working-directory: ./editors/vscode
- name: Build tinymist library
run: yarn build
working-directory: ./crates/tinymist-core
- name: Pack tinymist npm library
run: |
npm pack > package-name
mv $(cat package-name) tinymist-${{ env.target }}.tar.gz
working-directory: ./crates/tinymist-core
- name: Upload tinymist npm library
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}-npm
path: crates/tinymist-core/tinymist-${{ env.target }}.tar.gz
- name: Package extension
if: "!fromJson(env.isNightly)"
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
working-directory: ./editors/vscode
- name: Package extension (Nightly)
if: fromJson(env.isNightly)
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
working-directory: ./editors/vscode
- name: Upload tinymist VSIX artifact
uses: actions/upload-artifact@v4
with:
name: tinymist-${{ env.target }}.vsix
path: editors/vscode/tinymist-${{ env.target }}.vsix
release:
runs-on: ubuntu-latest
needs: [build, build_alpine]
if: success() && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "artifacts/*/*"
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
publish:
runs-on: ubuntu-latest
needs: [build]
env:
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
if: success() && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc')
steps:
- uses: actions/download-artifact@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install deps
run: yarn install
- name: Deploy to VS Code Marketplace
if: fromJson(env.isRelease)
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
env:
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
- name: Deploy to OpenVSX
if: fromJson(env.isRelease)
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
env:
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
- name: Deploy to VS Code Marketplace (Nightly)
if: fromJson(env.isNightly)
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
env:
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
- name: Deploy to OpenVSX (Nightly)
if: fromJson(env.isNightly)
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
env:
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}