Skip to content
Open
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6

# Cache Rust toolchain and cargo registry
- name: Cache Rust
uses: actions/cache@v4
Expand All @@ -36,24 +36,28 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('versions.txt') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install mdBook and plugins (Linux)
if: runner.os != 'Windows'
run: |
chmod +x scripts/install-tools.sh
./scripts/install-tools.sh

- name: Install mdBook and plugins (Windows)
if: runner.os == 'Windows'
run: .\scripts\install-tools.ps1


# Install Swift for testing Swift code examples in the book (Ubuntu only; setup-swift does not support Windows)
- name: Setup Swift
if: runner.os != 'Windows'
uses: swift-actions/setup-swift@v2

- name: Build with mdBook
run: mdbook build ./better-code

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: mdbook-build-${{ matrix.os }}
path: ./better-code/book
retention-days: 1

9 changes: 9 additions & 0 deletions better-code/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ enable = true
[output.html.print]
enable = true

[output.html.code.hidelines]
swift = "#"

[preprocessor.katex]

# Tests all Swift code blocks during `mdbook build`
# supported-platforms: Only run on these platforms (python3 sys.platform values); omitted => run on all
[output.swift-test]
command = "python3 ../../../scripts/mdbook-swift-test.py"
# Note: setup-swift@v3 does not support Windows
supported-platforms = ["linux", "darwin"]
Loading
Loading