From b49615100c0cbb00b00a7a983ff665fcab79eb05 Mon Sep 17 00:00:00 2001 From: Vijay Janapa Reddi Date: Tue, 27 Jan 2026 21:16:32 -0500 Subject: [PATCH] feat(ci): add PDF-only update workflow Allows updating paper and guide PDFs without version bumps or site changes. --- .github/workflows/tinytorch-update-pdfs.yml | 174 ++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 .github/workflows/tinytorch-update-pdfs.yml diff --git a/.github/workflows/tinytorch-update-pdfs.yml b/.github/workflows/tinytorch-update-pdfs.yml new file mode 100644 index 000000000..d64b4713e --- /dev/null +++ b/.github/workflows/tinytorch-update-pdfs.yml @@ -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