vision-rs 0.1.1

A high-performance computer vision SDK for Rust.
name: Deploy docs site

on:
  push:
    branches: [ main ]

jobs:
  deploy-docs:
    name: Build and deploy vision-rs.teenygrad.org
    runs-on: ubuntu-latest
    # Cargo.toml's [patch.crates-io] unconditionally resolves teeny-* deps
    # to ../teenygrad/... -- must exist as an actual sibling directory.
    # actions/checkout refuses a path outside github.workspace (confirmed
    # via a live failed run on ci.yml), so both repos are checked out as
    # sibling subdirectories of the workspace instead, with this job's
    # working directory pointed at the vision-rs one.
    defaults:
      run:
        working-directory: vision-rs
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: vision-rs

      - name: Checkout teenygrad (sibling dependency)
        uses: actions/checkout@v4
        with:
          repository: teenygrad/teenygrad
          path: teenygrad
          submodules: true

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry and build artifacts
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: vision-rs

      # The cuda feature (on by default) pulls in teeny-cuda, whose build.rs
      # unconditionally runs bindgen against real CUDA headers -- installed
      # so docs-site/build.sh's `nvcc` detection picks it up and builds the
      # full-feature API docs. Only -dev packages (no driver/dkms) -- see
      # ci.yml or teenygrad's deploy-docs.yml for why not the
      # Jimver/cuda-toolkit action. cuda-profiler-api-13-2 is a separate
      # package from cuda-cudart-dev (teeny-cuda's wrapper.h includes
      # cuda_profiler_api.h directly). /usr/local/cuda/bin isn't on PATH by
      # default even after install -- add it explicitly, or docs-site/
      # build.sh's `command -v nvcc` check silently skips teeny-cuda/
      # teeny-kernels (as it has been doing on teenygrad's own
      # deploy-docs.yml -- a real, previously undiscovered gap there too).
      - name: Install CUDA toolkit
        run: |
          wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring.deb
          sudo dpkg -i /tmp/cuda-keyring.deb
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            cuda-nvcc-13-2 cuda-cudart-dev-13-2 cuda-nvrtc-dev-13-2 cuda-driver-dev-13-2 cuda-profiler-api-13-2
          echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"

      - name: Install mdbook + mdbook-mermaid
        run: |
          cargo install mdbook --locked
          cargo install mdbook-mermaid --locked

      - name: Build docs site
        run: ./docs-site/build.sh

      - name: Set up SSH agent for Kamal
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.KAMAL_SSH_PRIVATE_KEY }}

      - name: Deploy via Kamal
        env:
          KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
        run: |
          docker run --rm \
            -v "$PWD:/workdir" -w /workdir \
            -v "$SSH_AUTH_SOCK:/ssh-agent" -e SSH_AUTH_SOCK=/ssh-agent \
            -v /var/run/docker.sock:/var/run/docker.sock \
            -e KAMAL_REGISTRY_PASSWORD \
            ghcr.io/basecamp/kamal:latest deploy