brkrs 0.0.1

Breakout/Arkanoid-style game built in Rust using the Bevy engine, with physics powered by bevy_rapier3d
Documentation
name: Deploy WASM to GitHub Pages

on:
  push:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown

      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --no-install-recommends -y pkg-config libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev clang lld

      - name: Cache cargo registry
        if: ${{ github.event_name == 'push' }}
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ github.ref_name }}

      - name: Cache cargo index
        if: ${{ github.event_name == 'push' }}
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ github.ref_name }}

      - name: Cache target directory
        if: ${{ github.event_name == 'push' }}
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-target-wasm-${{ hashFiles('**/Cargo.lock') }}-${{ github.ref_name }}

      - name: Populate WASM cache (compile)
        # Precompile the wasm target so the target/ cache gets populated
        run: |
          cargo fetch --locked
          cargo build --release --target wasm32-unknown-unknown

      - name: Install wasm-bindgen
        run: cargo install wasm-bindgen-cli --version 0.2.105

      - name: Prepare deployment
        run: |
          mkdir -p deploy
          cp wasm/index.html wasm/restart-audio-context.js deploy/
          cp -r assets deploy/
          wasm-bindgen --out-dir deploy --target web target/wasm32-unknown-unknown/release/brkrs.wasm

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.13"
          cache: "pip"
          cache-dependency-path: docs/requirements.txt

      - name: Install Python dependencies
        run: pip install -r docs/requirements.txt

      - name: Generate rustdoc
        run: cargo doc --no-deps --all-features

      - name: Stage rustdoc artifacts
        run: |
          chmod +x scripts/stage-rustdoc.sh
          ./scripts/stage-rustdoc.sh

      - name: Build Sphinx documentation
        run: sphinx-build -W -b html docs/ docs/_build/html

      - name: Copy documentation to deploy/docs
        run: |
          mkdir -p deploy/docs
          cp -r docs/_build/html/* deploy/docs/

      - name: Setup Pages
        uses: actions/configure-pages@v4

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: deploy

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4