Added specialized patching script for LaTeX equations #143
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modified from: https://github.com/choldgraf/deploy_configurations/blob/master/.github/workflows/main.yml | |
# Note: lint with https://rhysd.github.io/actionlint/ | |
name: Publish JupyterBook to GitHub Pages | |
on: | |
push: # trigger build only when push to master | |
branches: | |
- main | |
- test-gh-actions # GH actions test branch | |
permissions: | |
id-token: write | |
pages: write | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.10.15 | |
- name: Install Python dependencies | |
run: | | |
sudo apt-get install python3-pip | |
pip install numpy | |
pip install sympy | |
pip install matplotlib | |
pip install jupyter-book | |
pip install ghp-import | |
PATH="${PATH}:${HOME}/.local/bin" | |
- name: Build book HTML | |
run: | | |
jupyter-book build ./book | |
- name: Push built book HTML as artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "book/_build/html" | |
- name: Deploy book HTML to Github Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- name: Install PDF build dependencies | |
run: | | |
sudo apt-get update | |
# TeX tools | |
sudo apt-get install texlive-latex-base \ | |
texlive-latex-extra \ | |
texlive-fonts-extra \ | |
texlive-xetex latexmk | |
# Image tools | |
sudo apt-get install libpng-dev libjpeg-dev libtiff-dev imagemagick | |
# SVG processing tools | |
sudo apt-get install inkscape | |
- name: Build PDF of book | |
continue-on-error: true | |
run: | | |
jupyter-book build book --builder latex | |
# patch output latex | |
python ./book/patch.py | |
# build pdf (sphinx creates a makefile for us) | |
cd ./book/_build/latex/ | |
make | |
# move built book out of build folder | |
mv elara-handbook.pdf ../../elara-handbook.pdf | |
- name: Show debug logs | |
run: | | |
cat elara-handbook.log # debug | |
- name: Output build artifacts for debugging | |
run: | | |
# go back to root of repo | |
cd ../../../ | |
# we use temp.sh, a temporary file host service | |
echo "PDF build log" | |
curl -F "file=@book/_build/latex/elara-handbook.log" https://temp.sh/upload | |
echo "TeX generated (may be incomplete)" | |
curl -F "file=@book/_build/latex/elara-handbook.tex" https://temp.sh/upload | |
echo "PDF generated (may be incomplete)" | |
curl -F "file=@book/_build/latex/elara-handbook.pdf" https://temp.sh/upload | |
- name: Upload book PDF to Github releases | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
pip install github-release-retry | |
github-release-retry \ | |
--user elaraproject \ | |
--repo elara-handbook \ | |
--tag_name v0.0.0-$(git rev-parse HEAD | cut -c 1-8) \ | |
--prerelease \ | |
--body_string "Automatically generated from book sources via Github Actions" \ | |
./book/elara-handbook.pdf |