name: Deploy Documentation

on:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      
      - name: Set up Rust
        uses: dtolnay/rust-toolchain@stable
      
      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install -r docs/requirements.txt
          pip install maturin
      
      - name: Build Rust extension
        env:
          PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
        run: |
          cd python-groggy
          maturin build --release
          pip install target/wheels/*.whl
      
      - name: Build and deploy documentation
        run: mkdocs gh-deploy --force
