Initial commit #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Book | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Rust toolchain | |
run: | | |
rustup toolchain install stable --no-self-update --profile minimal | |
rustup target add wasm32-unknown-unknown | |
- name: Set up Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install latest mdbook | |
run: | | |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') | |
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" | |
mkdir bin | |
curl -sSL $url | tar -xz --directory=bin | |
echo "$(pwd)/bin" >> $GITHUB_PATH | |
- name: Install mdBook plugins | |
run: cargo install mdbook-trunk | |
- name: Run tests | |
run: mdbook test | |
working-directory: book | |
deploy: | |
needs: test | |
name: Deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Rust toolchain | |
run: | | |
rustup toolchain install stable --no-self-update --profile minimal | |
rustup target add wasm32-unknown-unknown | |
- name: Set up Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install Trunk | |
run: cargo install trunk | |
- name: Install latest mdbook | |
run: | | |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') | |
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" | |
mkdir mdbook | |
curl -sSL $url | tar -xz --directory=./mdbook | |
echo `pwd`/mdbook >> $GITHUB_PATH | |
- name: Install mdBook plugins | |
run: cargo install mdbook-tabs mdbook-trunk | |
- name: Install Node.js dependencies | |
run: npm install | |
- name: Build Book | |
run: mdbook build | |
working-directory: book | |
- name: Combine Book Outputs | |
run: mdbook-trunk combine | |
working-directory: book | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: 'book/dist' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |