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
name: Deploy Documentation
on:
push:
branches:
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout sibling fugue (path dependency)
run: git clone --depth 1 --branch "${GITHUB_HEAD_REF:-main}" https://github.com/alexnodeland/fugue.git "$GITHUB_WORKSPACE/../fugue" || git clone --depth 1 --branch main https://github.com/alexnodeland/fugue.git "$GITHUB_WORKSPACE/../fugue"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install mdbook
run: |
mkdir -p $HOME/.local/bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.44/mdbook-v0.4.44-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C $HOME/.local/bin
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-docs-
- name: Build rustdoc
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --enable-index-page -Zunstable-options
- name: Build fugue-evo-wasm package
run: wasm-pack build crates/fugue-evo-wasm --target web --release
- name: Build mdbook
run: mdbook build docs
- name: Combine documentation
run: |
# Copy rustdoc into mdbook output under /api
mkdir -p docs/book/api
cp -r target/doc/* docs/book/api/
# Serve the wasm package next to the book so the explorable
# widgets and playground can run the real crate (see
# docs/fugue-evo-wasm-loader.js, which imports <site>/pkg/).
mkdir -p docs/book/pkg
cp crates/fugue-evo-wasm/pkg/fugue_evo_wasm.js \
crates/fugue-evo-wasm/pkg/fugue_evo_wasm_bg.wasm \
crates/fugue-evo-wasm/pkg/package.json \
docs/book/pkg/
# Create a redirect from api/index.html to the main crate
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=fugue_evo/index.html"></head><body>Redirecting to <a href="fugue_evo/index.html">fugue_evo</a>...</body></html>' > docs/book/api/index.html
# Copy CNAME for custom domain
cp docs/CNAME docs/book/CNAME
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/book
deploy:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4