criterion 0.8.2

Statistics-driven micro-benchmarking library
Documentation
name: Build book and publish to GHCR

on:
  push:
    branches:
      - master
    paths:
      - "book/**"
      - ".github/workflows/book.yaml"

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  contents: read
  packages: write # push to GHCR

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  REF_MUTABLE: ghcr.io/criterion-rs/criterion.rs-book:latest
  REF_IMMUTABLE: ghcr.io/criterion-rs/criterion.rs-book:${{ github.sha }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Install mdBook
        uses: jontze/action-mdbook@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          mdbook-version: "~0.4.52" # mdbook 0.5 is not compatible with linkcheck and requires linkcheck2, see https://github.com/jontze/action-mdbook/issues/671
          use-linkcheck: true
          use-mermaid: true
          use-toc: true
          use-opengh: true
          use-admonish: true
          use-katex: true
      - name: Build Book
        run: |
          set -euo pipefail
          cd book && mdbook build
      - name: Create tarball
        run: |
          set -euo pipefail
          tar -czf book.tar.gz -C book/book/html .
      - name: Setup ORAS
        uses: oras-project/setup-oras@v1
      - name: Login to GHCR
        run: |
          echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u "${{ github.actor }}" --password-stdin
      - name: Push tarball as OCI artifact (mutable latest)
        run: |
          set -euo pipefail
          oras push "${REF_MUTABLE}" \
            book.tar.gz:application/gzip \
            --annotation org.opencontainers.image.title="book.tar.gz" \
            --annotation org.opencontainers.image.source="${{ github.repository }}" \
            --annotation org.opencontainers.image.revision="${{ github.sha }}"
      - name: Copy to immutable SHA tag
        run: |
          set -euo pipefail
          oras copy "${REF_MUTABLE}" "${REF_IMMUTABLE}"
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v4
        with:
          token: ${{ secrets.DISPATCH_TOKEN }}
          repository: criterion-rs/criterion-rs.github.io
          event-type: publish-book