Skip to content

fix: labs(alt:) fills in plot alt text (#57) #220

fix: labs(alt:) fills in plot alt text (#57)

fix: labs(alt:) fills in plot alt text (#57) #220

Workflow file for this run

name: Deploy Documentation
on:
push:
branches: [ main ]
paths:
- "docs/**"
- "lib.typ"
- "src/**"
- "examples/**"
- "tools/typstdoc/**"
- "tools/package.sh"
- "typst.toml"
- "CHANGELOG.md"
- ".github/workflows/deploy.yml"
workflow_dispatch:
workflow_call:
permissions:
contents: read
pages: write
id-token: write
# GitHub Pages only accepts one deployment at a time; queue instead of cancel.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
resolve:
name: Resolve build matrix
runs-on: ubuntu-latest
# Skip the bump-version commit on main; the Release workflow deploys docs
# itself via its `pages` job (workflow_call), so this push would double-deploy.
if: >-
${{ github.event_name != 'push'
|| !startsWith(github.event.head_commit.message, 'ci: bump version to') }}
outputs:
typst-version: ${{ steps.typst-version.outputs.version }}
tag: ${{ steps.latest-tag.outputs.tag }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Read Typst version from typst.toml
id: typst-version
shell: bash
run: |
set -euo pipefail
version=$(awk -F'"' '/^compiler[[:space:]]*=/ { print $2; exit }' typst.toml)
[[ -n "$version" ]] || { echo "::error::compiler not found in typst.toml"; exit 1; }
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Resolve latest release tag
id: latest-tag
shell: bash
run: |
LATEST_TAG=$(git tag -l --sort=-v:refname '[0-9]*' | head -n 1)
echo "tag=${LATEST_TAG}" >> "${GITHUB_OUTPUT}"
if [ -z "${LATEST_TAG}" ]; then
echo "No release tag found; release site will be skipped."
else
echo "Latest release tag: ${LATEST_TAG}"
fi
- name: Build render matrix
id: matrix
shell: bash
env:
LATEST_TAG: ${{ steps.latest-tag.outputs.tag }}
run: |
set -euo pipefail
# Navbar version-switch targets need absolute URLs: relative paths cannot
# reach the stable root from deep dev pages. Derive them from the site URL.
SITE_URL=$(awk '/^[[:space:]]*site-url:/ { sub(/^[[:space:]]*site-url:[[:space:]]*/, ""); gsub(/["'\'']/, ""); print; exit }' docs/_quarto.yml)
[[ -n "${SITE_URL}" ]] || { echo "::error::site-url not found in docs/_quarto.yml"; exit 1; }
if [ -n "${LATEST_TAG}" ]; then
# Release at root (tagged ref), dev at /dev/ (triggering ref, i.e. main).
# Switch link: release points to dev, dev points back to the stable root.
matrix='{"include":[{"profile":"release","ref":"'"${LATEST_TAG}"'","version":"'"${LATEST_TAG}"'","switch_label":"Development version","switch_href":"'"${SITE_URL}/dev/"'","assets_dir":""},{"profile":"dev","ref":"","version":"dev","switch_label":"Stable ('"${LATEST_TAG}"')","switch_href":"'"${SITE_URL}/"'","assets_dir":"docs/_site/dev"}]}'
else
# No release yet: dev content at root, single site with nothing to switch to.
matrix='{"include":[{"profile":"no-release","ref":"","version":"dev","switch_label":"","switch_href":"","assets_dir":"docs/_site"}]}'
fi
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
build:
name: Render ${{ matrix.profile }} site
needs: resolve
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.resolve.outputs.matrix) }}
env:
GH_TOKEN: ${{ github.token }}
QUARTO_TYPST: typst
VERSION: ${{ matrix.version }}
VERSION_SWITCH: ${{ matrix.switch_label }}
VERSION_SWITCH_URL: ${{ matrix.switch_href }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
# Website framework, tooling, and content always come from main; only the
# Typst code is pinned to the release tag so stable and dev stay near-identical.
- name: Pin Typst code to release ref
if: ${{ matrix.ref != '' }}
shell: bash
run: |
set -euo pipefail
git checkout "${{ matrix.ref }}" -- examples src lib.typ
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ needs.resolve.outputs.typst-version }}
- name: Set up Quarto CLI
uses: quarto-dev/quarto-actions/setup@v2
with:
version: release
# Computed once so the install page and the downloadable archive carry the
# same dated version. A date is a valid Typst (3-integer) version and marks
# the build as a development snapshot.
- name: Resolve dev version
shell: bash
run: echo "DEV_VERSION=$(date -u +%Y.%-m.%-d)" >> "${GITHUB_ENV}"
- name: Render site
shell: bash
run: quarto render docs --profile "${{ matrix.profile }}"
- name: Package development version
if: ${{ matrix.assets_dir != '' }}
shell: bash
run: tools/package.sh archive "${{ matrix.assets_dir }}" gribouille "${DEV_VERSION}"
- name: Upload site artifact
uses: actions/upload-artifact@v7
with:
name: site-${{ matrix.profile }}
path: docs/_site
retention-days: 1
deploy:
name: Deploy docs to GitHub Pages
needs: [ resolve, build ]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download site artifacts
uses: actions/download-artifact@v8
with:
pattern: site-*
merge-multiple: true
path: docs/_site
- name: Prepare site for deployment
shell: bash
run: touch docs/_site/.nojekyll
- name: Configure GitHub Pages
uses: actions/configure-pages@v6
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: "./docs/_site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Summary
shell: bash
env:
LATEST_TAG: ${{ needs.resolve.outputs.tag }}
PAGE_URL: ${{ steps.deployment.outputs.page_url }}
run: |
{
echo "## Documentation deploy"
echo ""
if [ -n "${LATEST_TAG}" ]; then
echo "- Root site source: \`${LATEST_TAG}\` (release)"
echo "- Dev site source: \`main\`"
echo "- Root URL: ${PAGE_URL}"
echo "- Dev URL: ${PAGE_URL}dev/"
else
echo "- Root site source: \`main\` (no release tag yet)"
echo "- Root URL: ${PAGE_URL}"
fi
} >> "${GITHUB_STEP_SUMMARY}"