feat(ci): add PDF-only update workflow

Allows updating paper and guide PDFs without version bumps or site changes.
This commit is contained in:
Vijay Janapa Reddi
2026-01-27 21:16:32 -05:00
parent a04fe4c6f6
commit b49615100c

View File

@@ -0,0 +1,174 @@
name: '🔥 TinyTorch · 📄 Update PDFs Only'
# =============================================================================
# PDF-Only Update Workflow
# =============================================================================
# Rebuilds and deploys PDFs without touching the website, version, or tags.
# Use this when you only need to update the paper or guide PDF.
# =============================================================================
on:
workflow_dispatch:
inputs:
update_paper:
description: 'Update Research Paper PDF'
type: boolean
default: true
update_guide:
description: 'Update Course Guide PDF'
type: boolean
default: true
permissions:
contents: write
jobs:
build-paper:
name: '📑 Build Research Paper'
runs-on: ubuntu-latest
if: inputs.update_paper
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
with:
ref: main
- name: 📑 Compile Paper with LuaLaTeX
uses: xu-cheng/latex-action@v3
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: 7
build-guide:
name: '📚 Build Course Guide'
runs-on: ubuntu-latest
if: inputs.update_guide
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
with:
ref: main
- 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@v3
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: 7
deploy-pdfs:
name: '🚀 Deploy PDFs to gh-pages'
runs-on: ubuntu-latest
needs: [build-paper, build-guide]
if: always() && (needs.build-paper.result == 'success' || needs.build-guide.result == 'success')
steps:
- name: 📥 Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: 📥 Download Paper PDF
if: needs.build-paper.result == 'success'
uses: actions/download-artifact@v4
with:
name: TinyTorch-Paper
path: ./artifacts/paper
- name: 📥 Download Guide PDF
if: needs.build-guide.result == 'success'
uses: actions/download-artifact@v4
with:
name: TinyTorch-Guide
path: ./artifacts/guide
- name: 📁 Update PDFs in gh-pages
run: |
cd gh-pages
mkdir -p tinytorch/_static/downloads
if [ -f ../artifacts/paper/paper.pdf ]; then
cp ../artifacts/paper/paper.pdf tinytorch/_static/downloads/TinyTorch-Paper.pdf
echo "✅ Updated TinyTorch-Paper.pdf"
fi
if [ -f ../artifacts/guide/tinytorch-course.pdf ]; then
cp ../artifacts/guide/tinytorch-course.pdf tinytorch/_static/downloads/TinyTorch-Guide.pdf
echo "✅ Updated TinyTorch-Guide.pdf"
fi
echo ""
echo "📦 Downloads folder:"
ls -la tinytorch/_static/downloads/
- name: 🚀 Push to gh-pages
working-directory: gh-pages
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add tinytorch/_static/downloads/
git commit -m "📄 Update TinyTorch PDFs" || echo "No changes to commit"
git push origin gh-pages
summary:
name: '📊 Summary'
runs-on: ubuntu-latest
needs: [build-paper, build-guide, deploy-pdfs]
if: always()
steps:
- name: 📊 Generate Summary
run: |
echo "## 📄 TinyTorch PDF Update" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| PDF | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| 📑 Research Paper | ${{ needs.build-paper.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| 📚 Course Guide | ${{ needs.build-guide.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🚀 Deploy | ${{ needs.deploy-pdfs.result }} |" >> $GITHUB_STEP_SUMMARY