Site and docs overhaul #23
Workflow file for this run
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: build-doc-deploy | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: {} | |
jobs: | |
# build-python: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - name: Setup Python | |
# uses: actions/setup-python@v3 | |
# - run: pip install poetry | |
# - run: cd learning ; poetry build | |
cargo-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cache Cargo dependencies | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
build-rust: | |
runs-on: ubuntu-latest | |
needs: cargo-cache | |
steps: | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Build | |
run: cargo build --release --all-features | |
docs-rust: | |
needs: build-rust | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Generate docs | |
run: cargo doc --no-deps --target-dir=docs/api | |
docs-site: | |
needs: docs-rust | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v3 | |
- run: pip install -r docs/requirements.txt | |
- name: Export notebooks as examples | |
run: make ipynb2md | |
- name: MkDocs build | |
run: mkdocs build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: site | |
path: site | |
docs-deploy: | |
if: github.ref == 'refs/heads/main' | |
needs: docs-site | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: site | |
path: site | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: site | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
if: github.event_name != 'pull_request' |