name: Docs
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build site and rustdoc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup show
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install native audio dependencies
timeout-minutes: 15
run: python3 .github/scripts/apt_install.py libasound2-dev
- name: Build API documentation
run: cargo doc --workspace --no-deps --features native
env:
RUSTDOCFLAGS: -D warnings
- name: Install wasm-pack
env:
WASM_PACK_VERSION: '0.15.0'
run: |
target="wasm-pack-v${WASM_PACK_VERSION}-x86_64-unknown-linux-musl"
mkdir -p "$RUNNER_TEMP/wasm-pack"
curl -sSfL "https://github.com/rustwasm/wasm-pack/releases/download/v${WASM_PACK_VERSION}/${target}.tar.gz" | tar -xz --strip-components=1 -C "$RUNNER_TEMP/wasm-pack" "${target}/wasm-pack"
"$RUNNER_TEMP/wasm-pack/wasm-pack" --version
echo "$RUNNER_TEMP/wasm-pack" >> "$GITHUB_PATH"
- name: Build browser package for the site
run: wasm-pack build --target web --out-dir site/pkg --features web
- name: Assemble the site
run: |
set -euo pipefail
mkdir -p _site
cp -R target/doc/. _site/
cp -R site/. _site/
rm -f _site/.gitignore _site/pkg/.gitignore _site/pkg/README.md
mkdir -p _site/media _site/api
cp examples/media/BigBuckBunny.av1.mp4 _site/media/
echo '<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="0; url=../zvidlib/index.html"><link rel="canonical" href="../zvidlib/index.html"><a href="../zvidlib/index.html">zvidlib API documentation</a>' > _site/api/index.html
for required in index.html zvidlib/index.html pkg/zvidlib.js pkg/zvidlib_bg.wasm media/BigBuckBunny.av1.mp4; do
test -f "_site/$required" || { echo "::error::_site/$required is missing"; exit 1; }
done
du -sh _site
- uses: actions/upload-pages-artifact@v3
with:
path: _site
deploy:
name: Deploy to GitHub Pages
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4