constriction 0.4.2

Entropy coders for research and production (Rust and Python).
Documentation
name: website-from-source

on:
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  python-doc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: Set up Python 3.13
        uses: actions/setup-python@v5
        with:
          python-version: "3.13"

      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install poetry
          poetry install --no-root

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

      - name: Cache Rust dependencies
        uses: actions/cache@v4
        with:
          path: |
            target
            .cargo_home
            .cargo
          key: ${{ runner.os }}-pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-

      - name: checkout website template
        run: |
          git clone https://github.com/bamler-lab/constriction.git --branch website-template --single-branch website
          rm -rf website/.git
          CONSTRICTION_VERSION=`poetry run python get_version.py`
          echo "Found constriction version $CONSTRICTION_VERSION."
          sed -i "s/<\!-- CONSTRICTION_VERSION -->/$CONSTRICTION_VERSION/g" website/index.html

      - name: generate license file
        run: |
          cargo install cargo-quickinstall
          cargo quickinstall cargo-about
          cargo about generate --features=pybindings about.hbs > website/license.html
          wc -l website/license.html

      - name: generate python API reference
        run: |
          poetry run maturin develop --features pybindings
          poetry run python pythondoc.py website/apidoc/python
          mv website/apidoc/python/constriction/* website/apidoc/python/
          rmdir website/apidoc/python/constriction

      - name: Save artifact with website
        uses: actions/upload-artifact@v4
        with:
          name: website
          path: ./website

      - name: Deploy website to gh-pages branch
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./website
          commit_message: Deploy