name: '๐Ÿ”ฅ TinyTorch ยท ๐Ÿ“‘ Update PDFs' # ============================================================================= # 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@v6 with: ref: main - 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@v6 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@v6 with: ref: main - name: ๐Ÿ Setup Python uses: actions/setup-python@v6 with: python-version: '3.11' cache: 'pip' cache-dependency-path: 'tinytorch/site/requirements.txt' - name: ๐ŸŸข Setup Node.js (for Mermaid) uses: actions/setup-node@v6 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@v6 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@v6 with: ref: gh-pages path: gh-pages - name: ๐Ÿ“ฅ Download Paper PDF if: needs.build-paper.result == 'success' uses: actions/download-artifact@v7 with: name: TinyTorch-Paper path: ./artifacts/paper - name: ๐Ÿ“ฅ Download Guide PDF if: needs.build-guide.result == 'success' uses: actions/download-artifact@v7 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