-
Notifications
You must be signed in to change notification settings - Fork 62
424 lines (351 loc) Β· 13.2 KB
/
rust.yml
File metadata and controls
424 lines (351 loc) Β· 13.2 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
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
name: Rust
on:
push:
branches:
- master
tags:
- "**"
pull_request:
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1
jobs:
pre_job:
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4
with:
paths_ignore: '["docs/**", "*.md"]'
build:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
include:
- name: Linux x86_64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
artifact_name: squawk-linux-x64
vscode_artifact_name: linux-x64
- name: Linux arm64
os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
artifact_name: squawk-linux-arm64
vscode_artifact_name: linux-arm64
rustflags: "-C linker=aarch64-linux-gnu-gcc"
- name: Linux Alpine x86_64
os: ubuntu-22.04
target: x86_64-unknown-linux-musl
artifact_name: squawk-linux-musl-x64
vscode_artifact_name: alpine-x64
rustflags: "-C linker=rust-lld"
- name: Linux Alpine arm64
os: ubuntu-22.04
target: aarch64-unknown-linux-musl
artifact_name: squawk-linux-musl-arm64
vscode_artifact_name: alpine-arm64
rustflags: "-C linker=rust-lld"
- name: Windows x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: squawk-windows-x64.exe
vscode_artifact_name: win32-x64
- name: macOS x86_64
os: macos-latest
target: x86_64-apple-darwin
artifact_name: squawk-darwin-x64
vscode_artifact_name: darwin-x64
- name: macOS arm64
os: macos-latest
target: aarch64-apple-darwin
artifact_name: squawk-darwin-arm64
vscode_artifact_name: darwin-arm64
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update apt repositories
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-musl' || matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update
- name: Install AArch64 target toolchain
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get install gcc-aarch64-linux-gnu
- name: Install x86_64-musl target toolchain
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install musl-tools
- name: Install Zig
if: matrix.target == 'aarch64-unknown-linux-musl'
uses: mlugg/setup-zig@v2
with:
version: 0.11.0
- name: Install Toolchain
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
with:
toolchain: 1.93
targets: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
- name: Build
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
mkdir -p "$RUNNER_TEMP/bin"
printf '%s\n' '#!/usr/bin/env bash' 'args=()' 'skip_next=0' 'for arg in "$@"; do' ' if [ "$skip_next" = "1" ]; then' ' skip_next=0' ' continue' ' fi' ' case "$arg" in' ' --target=*|-target=*) continue ;;' ' --target|-target) skip_next=1; continue ;;' ' esac' ' args+=("$arg")' 'done' 'exec zig cc -target aarch64-linux-musl "${args[@]}"' > "$RUNNER_TEMP/bin/aarch64-linux-musl-gcc"
printf '%s\n' '#!/usr/bin/env bash' 'exec zig ar "$@"' > "$RUNNER_TEMP/bin/aarch64-linux-musl-ar"
printf '%s\n' '#!/usr/bin/env bash' 'exec zig ranlib "$@"' > "$RUNNER_TEMP/bin/aarch64-linux-musl-ranlib"
chmod +x "$RUNNER_TEMP/bin/aarch64-linux-musl-gcc" "$RUNNER_TEMP/bin/aarch64-linux-musl-ar" "$RUNNER_TEMP/bin/aarch64-linux-musl-ranlib"
export PATH="$RUNNER_TEMP/bin:$PATH"
export CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc
export AR_aarch64_unknown_linux_musl=aarch64-linux-musl-ar
export RANLIB_aarch64_unknown_linux_musl=aarch64-linux-musl-ranlib
fi
RUSTFLAGS="${{ matrix.rustflags }}" cargo build --target ${{ matrix.target }} --release
shell: bash
- name: Rename artifact (windows)
if: matrix.target == 'x86_64-pc-windows-msvc'
run: mv target/${{ matrix.target }}/release/squawk.exe target/release/${{ matrix.artifact_name }}
- name: Rename artifact (linux, mac)
if: matrix.target != 'x86_64-pc-windows-msvc'
run: mv target/${{ matrix.target }}/release/squawk target/release/${{ matrix.artifact_name }}
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.artifact_name }}
path: target/release/${{ matrix.artifact_name }}
- name: VSCode - Make server dir
shell: bash
run: mkdir squawk-vscode/server
- name: VSCode - Copy binary into extension (windows)
if: matrix.target == 'x86_64-pc-windows-msvc'
shell: bash
run: cp target/release/${{ matrix.artifact_name }} squawk-vscode/server/squawk.exe
- name: VSCode - Copy binary into extension (linux, mac)
if: matrix.target != 'x86_64-pc-windows-msvc'
shell: bash
run: cp target/release/${{ matrix.artifact_name }} squawk-vscode/server/squawk
- name: VSCode - Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: VSCode - Setup node
uses: actions/setup-node@v3
with:
node-version-file: "squawk-vscode/package.json"
cache-dependency-path: "squawk-vscode/pnpm-lock.yaml"
cache: "pnpm"
- name: VSCode - Install JS dependencies
working-directory: "squawk-vscode"
run: pnpm install
- name: VSCode - Build
working-directory: "squawk-vscode"
run: pnpm exec vsce pack --no-dependencies --target ${{ matrix.vscode_artifact_name }}
- name: VSCode - Artifact
uses: actions/upload-artifact@v4
with:
name: squawk-vscode-${{ matrix.vscode_artifact_name }}
path: squawk-vscode/*.vsix
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/release/${{ matrix.artifact_name }}
squawk-vscode/*.vsix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm --version
- run: npm publish
publish-docker:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
attestations: write
id-token: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
type=ref,event=branch
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-playground:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: pnpm/action-setup@v2
with:
version: 9
- uses: actions/setup-node@v3
with:
node-version-file: "playground/package.json"
cache-dependency-path: "playground/pnpm-lock.yaml"
cache: "pnpm"
- name: Install JS dependencies
working-directory: "playground"
run: pnpm install
- name: Build
working-directory: "playground"
run: pnpm build
- name: Deploy to Netlify
if: startsWith(github.ref, 'refs/tags/')
uses: nwtgck/actions-netlify@v2
with:
publish-dir: "playground/dist"
production-branch: main
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
fails-without-credentials: true
enable-pull-request-comment: false
enable-commit-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.PLAYGROUND_NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.PLAYGROUND_NETLIFY_SITE_ID }}
lint:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Toolchain
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
with:
toolchain: 1.93
components: clippy, rustfmt
- name: Cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
- name: Get Clippy Version
run: cargo clippy --version
- name: Lint
run: ./s/lint
test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Toolchain
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
with:
toolchain: 1.93
- name: Cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
- name: Test
run: ./s/test
check_version:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Check versions are consistent
run: ./s/check-version
publish-crates:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Toolchain
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
with:
toolchain: 1.93
- name: Cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # pin@v2
- name: Publish to crates.io
run: cargo publish --workspace
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
publish-vscode:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: "squawk-vscode/package.json"
cache-dependency-path: "squawk-vscode/pnpm-lock.yaml"
cache: "pnpm"
- name: Install JS dependencies
working-directory: "squawk-vscode"
run: pnpm install
- name: Download all VS Code artifacts
uses: actions/download-artifact@v4
with:
pattern: squawk-vscode-*
path: ./dist
- name: Publish Extension (VS Code Marketplace)
working-directory: ./squawk-vscode
run: pnpm exec vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../dist/squawk-vscode-*/*.vsix
- name: Publish Extension (Open VSX)
working-directory: ./squawk-vscode
run: pnpm exec ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../dist/squawk-vscode-*/*.vsix
timeout-minutes: 2