-
Notifications
You must be signed in to change notification settings - Fork 2
367 lines (321 loc) · 10.1 KB
/
gh-pages.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
name: github-pages
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-wasm:
name: Test Wasm
runs-on: macos-15
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
rs/wasm
- name: Cache Cargo
id: cache-cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: wasm-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Cargo
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: |
cargo install wasm-bindgen-cli
cargo install wasm-pack
- name: Test Wasm
working-directory: rs/wasm
run: |
wasm-pack test --headless --chrome
build-wasm:
name: Build Wasm
runs-on: macos-15
needs: test-wasm
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
rs/wasm
- name: Cache Cargo
id: cache-cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: wasm-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Cargo
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: |
cargo install wasm-bindgen-cli
cargo install wasm-pack
- name: Build Wasm
working-directory: rs/wasm
run: |
wasm-pack build --target web
- name: Upload wasm_pkg
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: wasm-book
path: rs/wasm/pkg
if-no-files-found: error
test-js:
name: Test JS
runs-on: macos-15
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
js
- name: Setup Bun
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
with:
bun-version-file: ".bun-version"
no-cache: true
- name: Install
working-directory: js
run: |
bun install
- name: Test Bun
working-directory: js
run: |
bun test
build-js:
name: Build JS
runs-on: macos-15
needs: [test-js, build-wasm]
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
js
- name: Cache dependencies
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.bun/install/cache
js/node_modules
key: js-${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: js-${{ runner.os }}-bun-
- name: Download wasm_pkg
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: wasm-book
path: pkg
- name: Copy wasm_js
run: |
cp pkg/wasm_book.js js
cp pkg/wasm_book.d.ts js
- name: Setup Bun
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
with:
bun-version-file: ".bun-version"
no-cache: true
- name: Install
working-directory: js
run: |
bun install --production
bun create-highlight.bun.sh
- name: Build
working-directory: js
run: |
bun run build.js
- name: Upload JS
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: build-js
path: js/dist
if-no-files-found: error
build-scss:
name: Build SCSS
runs-on: macos-15
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
scss
scss/catppuccin
- name: Setup Bun
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
with:
bun-version-file: ".bun-version"
no-cache: true
- name: Build SCSS
working-directory: scss
run: |
bun install --production
bun run build.js
- name: Upload CSS
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: css
path: scss/dist
if-no-files-found: error
convert-woff2:
name: Convert WOFF2
runs-on: macos-15
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
fonts
- name: Cache Woff2 output
id: cache-woff2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: fonts/woff2
key: python-${{ runner.os }}-fonts-${{ hashFiles('fonts/**') }}
restore-keys: |
python-${{ runner.os }}-fonts-
- name: Install Poetry
if: steps.cache-woff2.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Dependencies
if: steps.cache-woff2.outputs.cache-hit != 'true'
working-directory: fonts
run: |
set -e
poetry install
- name: Convert and Copy Woff2
if: steps.cache-woff2.outputs.cache-hit != 'true'
working-directory: fonts
run: |
set -e
mkdir -p woff2
poetry run python convert.py NerdFontsSymbolsOnly/SymbolsNerdFontMono-Regular.ttf woff2
poetry run python convert.py Open_Sans/static/OpenSans-BoldItalic.ttf woff2
poetry run python convert.py Open_Sans/static/OpenSans-Italic.ttf woff2
cp "Fira Code/FiraCode-VF.woff2" woff2
- name: Upload font artifacts
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: woff2
path: fonts/woff2
if-no-files-found: error
test-mdbook-backend:
name: Test mdBook Backend
runs-on: macos-15
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
rs/mdbook-footnote
- name: Cache Cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: test-backend-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Test Cargo (mdbook-footnote)
working-directory: rs/mdbook-footnote
run: |
cargo test --verbose
build-and-deploy:
name: Build and Deploy
runs-on: macos-15
if: ${{ github.ref == 'refs/heads/main' }}
needs: [build-wasm, build-js, build-scss, convert-woff2, test-mdbook-backend]
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
sparse-checkout: |
.
rs/mdbook-footnote
src
theme
- name: Download All Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
path: artifacts
- name: Copy Files
run: |
cp artifacts/wasm-book/wasm_book_bg.wasm src
cp artifacts/build-js/* src
cp -r artifacts/woff2 src
cp -r artifacts/css src
- name: Cache Cargo
id: cache-cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: backend-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Backend
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: |
cargo install mdbook-admonish
cargo install mdbook-tailor
cargo install --path ./rs/mdbook-footnote
- name: Setup mdBook
uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 # v2
with:
mdbook-version: "0.4.43"
- name: Build mdBook
run: |
mdbook build
- name: Generate Page List
working-directory: book
run: |
sed \
-e 's|<ol class="section">|<ol>|g' \
-e 's|<li class="chapter-item expanded ">|<li>|g' \
-e 's| target="_parent"||g' \
toc.html > pagelist.html
- name: Remove Unneeded Files
working-directory: book
run: |
rm ayu-highlight.css
rm clipboard.min.js
rm elasticlunr.min.js
rm favicon.png
rm fonts.css
rm highlight.css
rm highlight.js
rm searcher.js
rm toc.html
rm toc.js
rm tomorrow-night.css
rm css/chrome.css
rm css/variables.css
rm mark.min.js
rm searchindex.js
rm -rf FontAwesome
rm -rf fonts
- name: List Segments
run: |
ls -alR book
- name: Deploy
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: book