Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 9fa330d

Browse files
committed
ci: copy ci script from tinymist
1 parent 8842218 commit 9fa330d

File tree

1 file changed

+121
-94
lines changed

1 file changed

+121
-94
lines changed

.github/workflows/release.yml

Lines changed: 121 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# stolen from https://github.com/nvarner/typst-lsp/blob/master/.github/workflows/release.yml
1+
# stolen from https://github.com/nvarner/tinymist/blob/master/.github/workflows/release.yml
22
name: CI
33
on:
44
push:
@@ -15,8 +15,6 @@ on:
1515
env:
1616
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
1717
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
18-
SCCACHE_GHA_ENABLED: "true"
19-
RUSTC_WRAPPER: "sccache"
2018

2119
jobs:
2220
pre_build:
@@ -40,6 +38,7 @@ jobs:
4038
rust-target: x86_64-pc-windows-msvc
4139
platform: win32
4240
arch: x64
41+
regular_build: 'true'
4342
- os: windows-latest
4443
rust-target: aarch64-pc-windows-msvc
4544
platform: win32
@@ -48,6 +47,7 @@ jobs:
4847
rust-target: x86_64-unknown-linux-gnu
4948
platform: linux
5049
arch: x64
50+
regular_build: 'true'
5151
- os: ubuntu-20.04
5252
rust-target: aarch64-unknown-linux-gnu
5353
platform: linux
@@ -56,134 +56,152 @@ jobs:
5656
rust-target: arm-unknown-linux-gnueabihf
5757
platform: linux
5858
arch: armhf
59-
- os: macos-11
59+
- os: macos-13
6060
rust-target: x86_64-apple-darwin
6161
platform: darwin
6262
arch: x64
63-
- os: macos-11
63+
- os: macos-13
6464
rust-target: aarch64-apple-darwin
6565
platform: darwin
6666
arch: arm64
67-
67+
regular_build: 'true'
6868
name: build (${{ matrix.platform }}-${{ matrix.arch }})
6969
runs-on: ${{ matrix.os }}
7070
env:
7171
target: ${{ matrix.platform }}-${{ matrix.arch }}
7272
steps:
7373
- uses: actions/checkout@v4
7474
with:
75+
repository: Myriad-Dreamin/tinymist
7576
submodules: recursive
76-
- name: Run sccache-cache
77-
uses: mozilla-actions/[email protected]
77+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
7878
- name: Install Node.js
7979
uses: actions/setup-node@v4
8080
with:
8181
node-version: 16
82-
- name: Build typst-dom
82+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
83+
- name: Install deps
84+
run: yarn install
85+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
86+
- name: Build typst-preview vscode extension
8387
run: |
8488
yarn
85-
yarn build
86-
working-directory: ./addons/typst-dom
87-
- name: Build frontend
88-
run: yarn
89-
working-directory: ./addons/frontend
90-
- name: Build vscode extension
89+
yarn run compile
90+
working-directory: ./contrib/typst-preview/editors/vscode
91+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
92+
- name: Build tinymist vscode extension
9193
run: |
9294
yarn
9395
yarn run compile
94-
working-directory: ./addons/vscode
96+
working-directory: ./editors/vscode
97+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
9598
- name: rust toolchain
9699
uses: dtolnay/rust-toolchain@stable
97100
with:
98101
targets: ${{ matrix.rust-target }}
102+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
99103
- name: Install llvm
100-
if: matrix.platform == 'linux'
104+
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
101105
run: |
102106
sudo apt-get update
103107
sudo apt-get install llvm
104108
- name: Install AArch64 target toolchain
105-
if: matrix.rust-target == 'aarch64-unknown-linux-gnu'
109+
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
106110
run: |
107111
sudo apt-get update
108112
sudo apt-get install gcc-aarch64-linux-gnu
109113
- name: Install ARM target toolchain
110-
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf'
114+
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
111115
run: |
112116
sudo apt-get update
113117
sudo apt-get install gcc-arm-linux-gnueabihf
114-
- name: Build typst-preview binary
118+
- name: Run rust-cache
119+
uses: Swatinem/rust-cache@v2
120+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
121+
- name: Build tinymist binary
115122
shell: pwsh
116123
run: |
117-
cargo build --release -p typst-preview --target ${{ matrix.rust-target }}
124+
cargo build --profile=gh-release -p tinymist --target ${{ matrix.rust-target }}
125+
if: startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true'
118126
- name: Rename debug symbols for windows
119-
if: matrix.platform == 'win32'
127+
if: matrix.platform == 'win32' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
128+
run: |
129+
cd target/${{ matrix.rust-target }}/gh-release
130+
cp tinymist.pdb tinymist-${{ env.target }}.pdb
131+
- name: Split debug symbols for linux
132+
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
120133
run: |
121-
cd target/${{ matrix.rust-target }}/release
122-
cp typst_preview.pdb typst_preview-${{ env.target }}.pdb
134+
cd target/${{ matrix.rust-target }}/gh-release
135+
llvm-objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
136+
llvm-objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
137+
- name: Collect debug symbols for mac
138+
if: matrix.platform == 'darwin' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
139+
run: |
140+
dsymutil -f "target/${{ matrix.rust-target }}/gh-release/tinymist"
141+
mv "target/${{ matrix.rust-target }}/gh-release/tinymist.dwarf" "target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf"
142+
- name: Copy binary to output directory
143+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
144+
shell: pwsh
145+
run: |
146+
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "editors/vscode/out/"
147+
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "contrib/typst-preview/editors/vscode/out/"
148+
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 { '' } )"
149+
- name: Test tinymist
150+
run: |
151+
cargo test --profile=gh-release --workspace --target ${{ matrix.rust-target }}
152+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true') && (matrix.platform == 'linux') && (matrix.arch == 'x64')
123153
- name: Upload split debug symbols for windows
124-
if: matrix.platform == 'win32'
154+
if: matrix.platform == 'win32' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
125155
uses: actions/upload-artifact@v4
126156
with:
127-
name: typst_preview-${{ env.target }}.pdb
128-
path: target/${{ matrix.rust-target }}/release/typst_preview-${{ env.target }}.pdb
129-
- name: Split debug symbols for linux
130-
if: matrix.platform == 'linux'
131-
run: |
132-
cd target/${{ matrix.rust-target }}/release
133-
llvm-objcopy --compress-debug-sections --only-keep-debug "typst-preview" "typst-preview-${{ env.target }}.debug"
134-
llvm-objcopy --strip-debug --add-gnu-debuglink="typst-preview-${{ env.target }}.debug" "typst-preview"
157+
name: tinymist-${{ env.target }}.pdb
158+
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.pdb
135159
- name: Upload split debug symbols for linux
136-
if: matrix.platform == 'linux'
160+
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
137161
uses: actions/upload-artifact@v4
138162
with:
139-
name: typst-preview-${{ env.target }}.debug
140-
path: target/${{ matrix.rust-target }}/release/typst-preview-${{ env.target }}.debug
163+
name: tinymist-${{ env.target }}.debug
164+
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.debug
141165
compression-level: 0
142-
- name: Collect debug symbols for mac
143-
if: matrix.platform == 'darwin'
144-
run: |
145-
dsymutil -f "target/${{ matrix.rust-target }}/release/typst-preview"
146-
mv "target/${{ matrix.rust-target }}/release/typst-preview.dwarf" "target/${{ matrix.rust-target }}/release/typst-preview-${{ env.target }}.dwarf"
147166
- name: Upload split debug symbols for mac
148-
if: matrix.platform == 'darwin'
167+
if: matrix.platform == 'darwin' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
149168
uses: actions/upload-artifact@v4
150169
with:
151-
name: typst-preview-${{ env.target }}.dwarf
152-
path: target/${{ matrix.rust-target }}/release/typst-preview-${{ env.target }}.dwarf
153-
- name: Copy binary to output directory
154-
shell: pwsh
155-
run: |
156-
cp "target/${{ matrix.rust-target }}/release/typst-preview$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "addons/vscode/out/"
157-
cp "target/${{ matrix.rust-target }}/release/typst-preview$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "typst-preview-${{ env.target }}$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )"
170+
name: tinymist-${{ env.target }}.dwarf
171+
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf
158172
- name: Upload binary artifact
173+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
159174
uses: actions/upload-artifact@v4
160175
with:
161-
name: typst-preview-${{ env.target }}
162-
path: typst-preview-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
163-
- name: Package extension
176+
name: tinymist-${{ env.target }}
177+
path: tinymist-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
178+
- name: Package typst-preview extension
179+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
164180
shell: pwsh
165181
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
166-
working-directory: ./addons/vscode
167-
- name: Upload VSIX artifact
182+
working-directory: ./contrib/typst-preview/editors/vscode
183+
- name: Package tinymist extension
184+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
185+
shell: pwsh
186+
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
187+
working-directory: ./editors/vscode
188+
- name: Upload typst-preview VSIX artifact
189+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
168190
uses: actions/upload-artifact@v4
169191
with:
170192
name: typst-preview-${{ env.target }}.vsix
171-
path: addons/vscode/typst-preview-${{ env.target }}.vsix
172-
- name: Upload frontend html
193+
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
194+
- name: Upload VSIX artifact
195+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
173196
uses: actions/upload-artifact@v4
174-
if: matrix.platform == 'linux' && matrix.arch == 'x64'
175197
with:
176-
name: index.html
177-
path: addons/vscode/out/frontend/index.html
178-
overwrite: true
179-
- name: Publish crates
180-
if: matrix.platform == 'linux' && matrix.arch == 'x64' && startsWith(github.ref, 'refs/tags/')
181-
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
182-
198+
name: tinymist-${{ env.target }}.vsix
199+
path: editors/vscode/tinymist-${{ env.target }}.vsix
183200

184201
build_alpine:
185202
name: build (x86_64-unknown-linux-musl)
186203
runs-on: ubuntu-latest
204+
if: startsWith(github.ref, 'refs/tags/')
187205
container:
188206
image: rust:alpine
189207
volumes:
@@ -199,52 +217,61 @@ jobs:
199217
uses: actions/checkout@v4
200218
with:
201219
submodules: recursive
202-
- name: Run sccache-cache
203-
uses: mozilla-actions/[email protected]
204-
- name: Build typst-dom
220+
- name: Run rust-cache
221+
uses: Swatinem/rust-cache@v2
222+
- name: Install deps
223+
run: yarn install
224+
- name: Build typst-preview vscode extension
205225
run: |
206226
yarn
207-
yarn build
208-
working-directory: ./addons/typst-dom
209-
- name: Build frontend
210-
run: yarn
211-
working-directory: ./addons/frontend
212-
- name: Build vscode extension
227+
yarn run compile
228+
working-directory: ./contrib/typst-preview/editors/vscode
229+
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
230+
- name: Build tinymist vscode extension
213231
run: |
214232
yarn
215233
yarn run compile
216-
working-directory: ./addons/vscode
217-
- name: Build typst-preview binary
234+
working-directory: ./editors/vscode
235+
- name: Build tinymist binary
218236
run: |
219-
cargo build --release -p typst-preview --target $RUST_TARGET
220-
mkdir -p addons/vscode/out
237+
cargo build --profile=gh-release -p tinymist --target $RUST_TARGET
221238
- name: Split debug symbols
222239
run: |
223-
cd target/$RUST_TARGET/release
224-
objcopy --compress-debug-sections --only-keep-debug "typst-preview" "typst-preview-${{ env.target }}.debug"
225-
objcopy --strip-debug --add-gnu-debuglink="typst-preview-${{ env.target }}.debug" "typst-preview"
240+
cd target/$RUST_TARGET/gh-release
241+
objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
242+
objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
226243
- name: Upload split debug symbols
227244
uses: actions/upload-artifact@v4
228245
with:
229-
name: typst-preview-${{ env.target }}.debug
230-
path: target/${{ env.RUST_TARGET }}/release/typst-preview-${{ env.target }}.debug
246+
name: tinymist-${{ env.target }}.debug
247+
path: target/${{ env.RUST_TARGET }}/gh-release/tinymist-${{ env.target }}.debug
231248
- name: Copy binary to output directory
232249
run: |
233-
cp "target/${{ env.RUST_TARGET }}/release/typst-preview" "addons/vscode/out/"
234-
cp "target/${{ env.RUST_TARGET }}/release/typst-preview" "typst-preview-${{ env.target }}"
250+
mkdir -p editors/vscode/out
251+
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "editors/vscode/out/"
252+
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "contrib/typst-preview/editors/vscode/out/"
253+
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "tinymist-${{ env.target }}"
235254
- name: Upload binary artifact
236255
uses: actions/upload-artifact@v4
237256
with:
238-
name: typst-preview-${{ env.target }}
239-
path: typst-preview-${{ env.target }}
240-
- name: Package extension
257+
name: tinymist-${{ env.target }}
258+
path: tinymist-${{ env.target }}
259+
- name: Package typst-preview extension
241260
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
242-
working-directory: ./addons/vscode
243-
- name: Upload VSIX artifact
261+
working-directory: ./contrib/typst-preview/editors/vscode
262+
- name: Package extension
263+
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
264+
working-directory: ./editors/vscode
265+
- name: Upload typst-preview VSIX artifact
244266
uses: actions/upload-artifact@v4
245267
with:
246268
name: typst-preview-${{ env.target }}.vsix
247-
path: addons/vscode/typst-preview-${{ env.target }}.vsix
269+
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
270+
- name: Upload tinymist VSIX artifact
271+
uses: actions/upload-artifact@v4
272+
with:
273+
name: tinymist-${{ env.target }}.vsix
274+
path: editors/vscode/tinymist-${{ env.target }}.vsix
248275

249276
release:
250277
runs-on: ubuntu-latest
@@ -270,21 +297,21 @@ jobs:
270297
omitDraftDuringUpdate: true
271298
omitNameDuringUpdate: true
272299
omitPrereleaseDuringUpdate: true
273-
bodyFile: "addons/vscode/CHANGELOG.md"
274300

275301
publish:
276302
runs-on: ubuntu-latest
277303
needs: [build]
278304
if: success() && startsWith(github.ref, 'refs/tags/')
279305
steps:
280306
- uses: actions/download-artifact@v4
281-
307+
- name: Install deps
308+
run: yarn install
282309
- name: Deploy to VS Code Marketplace
283-
run: npx vsce publish --packagePath $(find . -type f -iname '*.vsix')
310+
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'typst-preview-*.vsix') --skip-duplicate
284311
env:
285312
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
286313

287314
- name: Deploy to OpenVSX
288-
run: npx ovsx publish --packagePath $(find . -type f -iname '*.vsix')
315+
run: npx ovsx publish --packagePath $(find . -type f -iname 'typst-preview-*.vsix') --skip-duplicate
289316
env:
290317
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)