-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (110 loc) · 3.92 KB
/
nix.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
# https://github.com/NixOS/nixos-artwork/blob/35ebbbf01c3119005ed180726c388a01d4d1100c/logo/README.md#L5
name: ❄️
on:
push:
tags:
# Do not add v prefix: https://github.com/dprint/plugins/blob/75a3755b8734eee294214a7d7efc18145668a99f/README.md?plain=1#L27
# https://github.com/actions/runner/issues/1699#issuecomment-1046796067
- '[0-9]+.[0-9]+.[0-9]+'
branches: [main]
paths:
- '.github/workflows/nix.yml'
- '**.nix'
- 'flake.*'
- '**.rs'
- 'Cargo.*'
- 'example'
- 'Taskfile.yml'
pull_request:
paths:
- '.github/workflows/nix.yml'
- '**.nix'
- 'flake.*'
- '**.rs'
- 'Cargo.*'
- 'example'
- 'Taskfile.yml'
schedule:
# Every 10:42 JST
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '42 1 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 30
# outputs:
# wasm-zip-url: ${{ steps.upload.outputs.artifact-url }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
- run: nix develop --command echo 'This step should be done before any other "nix develop" steps because of measuring Nix build time'
- run: nix flake check
- run: nix flake show
- run: nix develop --command task deps
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
- run: nix develop --command task
- name: Upload WASM file as an artifact
# id: upload
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: 'plugins'
path: 'target/wasm32-unknown-unknown/release/dprint_plugin_typstyle.wasm'
check:
strategy:
fail-fast: false
# Syntax https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for 'n.0'
dprint-version: [
'', # empty means to latest: https://github.com/dprint/check/blob/2f1cf31537886c3bfb05591c031f7744e48ba8a1/action.yml#L8
'0.48.0', # selfup {"extract":"\\d[^']+","replacer":["dprint", "--version"], "nth": 2}
]
runs-on: ubuntu-24.04
timeout-minutes: 15
needs: [build]
# Don't use `nix develop` in this steps to avoid other devshell tools and make faster to run
steps:
- uses: actions/checkout@v4
- name: Install dprint
env:
DPRINT_CLI_VERSION: '${{ matrix.dprint-version }}'
run: |
curl -fsSL https://dprint.dev/install.sh | sh -s "$DPRINT_CLI_VERSION" > /dev/null 2>&1
echo "/home/runner/.dprint/bin" >> "$GITHUB_PATH"
- name: Install Task
uses: arduino/setup-task@v2
with:
version: '3.39.2' # selfup {"extract":"\\d\\.\\d+\\.\\d+","replacer":["task", "--version"], "nth": 3}
- name: Download pre-built plugin
env:
GH_TOKEN: ${{ github.token }}
run: |
gh run download '${{ github.run_id }}'
tree
- name: Make sure dependencies
run: |
dprint --version
task --version
diff --version
- name: Test
env:
PLUGIN_DIR: '${{ github.workspace }}/plugins/dprint_plugin_typstyle.wasm'
run:
task test
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-24.04
timeout-minutes: 15
needs: [build, check]
env:
GH_TOKEN: ${{ github.token }}
steps:
# Required to checkout for gh command
- uses: actions/checkout@v4
- run: |
gh run download '${{ github.run_id }}'
tree
mv plugins/dprint_plugin_typstyle.wasm plugins/plugin.wasm
- run: |
gh release create --verify-tag "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" plugins/plugin.wasm