Files
cs249r_book/.github/workflows/tinytorch-build-pdfs.yml
Salman Muin Kayser Chishti 07d2751b6a Upgrade GitHub Actions to latest versions
Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>
2026-02-19 09:20:11 +00:00

135 lines
4.5 KiB
YAML

name: '🔥 TinyTorch · 🔨 Build PDFs'
# =============================================================================
# PDF Build Workflow (Artifacts Only)
# =============================================================================
# Builds TinyTorch PDFs and uploads as artifacts.
# PDFs are injected into the site during deployment (not committed to repo).
#
# Use: Actions → TinyTorch Build PDFs → Run workflow
# =============================================================================
on:
workflow_dispatch:
# Can be called by publish workflows
workflow_call:
inputs:
ref:
description: "Git ref to checkout (branch, tag, or SHA)"
type: string
required: false
default: ''
outputs:
guide_built:
description: "Whether the guide PDF was built successfully"
value: ${{ jobs.build-pdf-guide.result == 'success' }}
paper_built:
description: "Whether the paper PDF was built successfully"
value: ${{ jobs.build-pdf-paper.result == 'success' }}
permissions:
contents: read
jobs:
build-pdf-guide:
name: '📚 Build Course Guide'
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'tinytorch/site/requirements.txt'
- name: 🟢 Setup Node.js (for Mermaid)
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 📦 Install Mermaid CLI
run: npm install -g @mermaid-js/mermaid-cli
- name: 📦 Install dependencies
working-directory: tinytorch
run: |
pip install --upgrade pip
pip install -r site/requirements.txt
pip install -e .
- name: 📚 Generate LaTeX
working-directory: tinytorch/site
run: |
jupyter-book build . --builder latex --config _config_pdf.yml --toc _toc_pdf.yml
python3 scripts/latex_postprocessor.py
cp _static/logos/fire-emoji.png _build/latex/
cp _static/logos/logo-mlsysbook.png _build/latex/
cp _static/images/tito.png _build/latex/
- name: 📚 Compile PDF with XeLaTeX
uses: xu-cheng/latex-action@v4
with:
root_file: tinytorch-course.tex
working_directory: tinytorch/site/_build/latex
latexmk_use_xelatex: true
- name: 📤 Upload PDF Guide
uses: actions/upload-artifact@v4
with:
name: TinyTorch-Guide
path: tinytorch/site/_build/latex/tinytorch-course.pdf
retention-days: 90
build-pdf-paper:
name: '📑 Build Research Paper'
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: 📑 Compile Paper with LuaLaTeX
uses: xu-cheng/latex-action@v4
with:
root_file: paper.tex
working_directory: tinytorch/paper
latexmk_use_lualatex: true
- name: 📤 Upload PDF Paper
uses: actions/upload-artifact@v4
with:
name: TinyTorch-Paper
path: tinytorch/paper/paper.pdf
retention-days: 90
summary:
name: '📊 Build Summary'
runs-on: ubuntu-latest
needs: [build-pdf-guide, build-pdf-paper]
if: always()
steps:
- name: 📊 Generate Summary
run: |
echo "## 📚 TinyTorch PDF Build" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| PDF | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| 📚 Course Guide | ${{ needs.build-pdf-guide.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| 📑 Research Paper | ${{ needs.build-pdf-paper.result }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Usage" >> $GITHUB_STEP_SUMMARY
echo "PDFs are uploaded as artifacts and will be injected during site deployment." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "To deploy with these PDFs, run the appropriate publish workflow:" >> $GITHUB_STEP_SUMMARY
echo "- **Live**: TinyTorch Publish (Live)" >> $GITHUB_STEP_SUMMARY
echo "- **Dev**: TinyTorch Preview (Dev)" >> $GITHUB_STEP_SUMMARY