fugue-evo 0.1.0

A Probabilistic Genetic Algorithm Library for Rust
Documentation
name: Deploy Documentation

on:
  push:
    branches: [main, master]
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build Documentation
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Checkout sibling fugue (path dependency)
        run: git clone --depth 1 --branch "${GITHUB_HEAD_REF:-main}" https://github.com/alexnodeland/fugue.git "$GITHUB_WORKSPACE/../fugue" || git clone --depth 1 --branch main https://github.com/alexnodeland/fugue.git "$GITHUB_WORKSPACE/../fugue"

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

      - name: Install mdbook
        run: |
          mkdir -p $HOME/.local/bin
          curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.44/mdbook-v0.4.44-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C $HOME/.local/bin
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-docs-

      - name: Build rustdoc
        run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: --enable-index-page -Zunstable-options

      - name: Build mdbook
        run: mdbook build docs

      - name: Combine documentation
        run: |
          # Copy rustdoc into mdbook output under /api
          mkdir -p docs/book/api
          cp -r target/doc/* docs/book/api/
          # Create a redirect from api/index.html to the main crate
          echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=fugue_evo/index.html"></head><body>Redirecting to <a href="fugue_evo/index.html">fugue_evo</a>...</body></html>' > docs/book/api/index.html
          # Copy CNAME for custom domain
          cp docs/CNAME docs/book/CNAME

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

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

  deploy:
    name: Deploy to GitHub Pages
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4