Skip to content

Improve setup and add small programmability introduction. #123

Improve setup and add small programmability introduction.

Improve setup and add small programmability introduction. #123

name: Publish tutorial
on:
push:
branches:
- master
jobs:
publish-tutorial:
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-rust
name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable
# Caching for tutorial stepper application
- id: cache-stepper
name: Cache stepper
uses: actions/cache@v3
with:
path: tutorial/stepper/target
key: ${{ runner.os }}-stepper-${{ hashFiles('tutorial/stepper/Cargo.lock') }}
restore-keys: ${{ runner.os }}-stepper-
# Run stepper to verify that tutorial code works, and to generate diffs.
- id: run-stepper
name: Run stepper
run: |
cd tutorial/stepper
cargo run -- --debug
- id: setup-mdbook
name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.34'
- id: install-cargo-binstall
name: Install cargo-binstall
uses: taiki-e/install-action@v2
with:
tool: cargo-binstall
# Copy files for hashing in the next step, as `hashFiles` only works inside the workspace, not the home directory.
- id: copy-files-for-hashing
name: Copy files for hashing into workspace
run: |
cp ~/.cargo/.crates.toml .crates.toml.hash
cp ~/.cargo/.crates2.json .crates2.json.hash
# Caching for cargo binaries, mainly for speeding up `install-mdbook-processors`.
- id: cache-cargo-binaries
name: Cache Cargo binaries
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-cargo-${{ hashFiles('.crates.toml.hash', '.crates2.json.hash') }}
restore-keys: ${{ runner.os }}-cargo-
- id: install-mdbook-preprocessors
name: Install mdBook preprocessors
run: cargo binstall --no-confirm --no-symlinks mdbook-admonish mdbook-external-links
# Caching for tutorial mdbook-diff2html application
- id: cache-mdbook-diff2html
name: Cache mdbook-diff2html
uses: actions/cache@v3
with:
path: tutorial/mdbook-diff2html/target
key: ${{ runner.os }}-mdbook-diff2html-${{ hashFiles('tutorial/mdbook-diff2html/Cargo.lock') }}
restore-keys: ${{ runner.os }}-mdbook-diff2html-
- id: install-mdbook-diff2html-preprocessor
name: Install mdbook-diff2html preprocessors
run: cargo install --path tutorial/mdbook-diff2html
- id: build
name: Build tutorial mdBook
run: |
cd tutorial
mdbook build
- id: deploy
name: Deploy to GitHub pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./tutorial/book