|
| 1 | +name: Build & Publish to GH Pages |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'publish*' |
| 6 | +jobs: |
| 7 | + publish: |
| 8 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v6 |
| 13 | + with: |
| 14 | + fetch-depth: 0 |
| 15 | + - name: Setup Anaconda |
| 16 | + uses: conda-incubator/setup-miniconda@v4 |
| 17 | + with: |
| 18 | + auto-update-conda: true |
| 19 | + auto-activate-base: true |
| 20 | + miniconda-version: 'latest' |
| 21 | + python-version: "3.13" |
| 22 | + environment-file: environment.yml |
| 23 | + activate-environment: quantecon |
| 24 | + - name: Install latex dependencies |
| 25 | + run: | |
| 26 | + sudo apt-get -qq update |
| 27 | + sudo apt-get install -y \ |
| 28 | + texlive-latex-recommended \ |
| 29 | + texlive-latex-extra \ |
| 30 | + texlive-fonts-recommended \ |
| 31 | + texlive-fonts-extra \ |
| 32 | + texlive-xetex \ |
| 33 | + latexmk \ |
| 34 | + xindy \ |
| 35 | + dvipng \ |
| 36 | + cm-super |
| 37 | + - name: Display Conda Environment Versions |
| 38 | + shell: bash -l {0} |
| 39 | + run: conda list |
| 40 | + - name: Display Pip Versions |
| 41 | + shell: bash -l {0} |
| 42 | + run: pip list |
| 43 | + # Download Build Cache from cache.yml |
| 44 | + - name: Download "build" folder (cache) |
| 45 | + uses: dawidd6/action-download-artifact@v21 |
| 46 | + with: |
| 47 | + workflow: cache.yml |
| 48 | + branch: main |
| 49 | + name: build-cache |
| 50 | + path: _build |
| 51 | + # TODO: pdf support |
| 52 | + # # Build Assets (Download Notebooks, PDF via LaTeX) |
| 53 | + # - name: Build PDF from LaTeX |
| 54 | + # shell: bash -l {0} |
| 55 | + # run: | |
| 56 | + # jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going |
| 57 | + # - name: Copy LaTeX PDF for GH-PAGES |
| 58 | + # shell: bash -l {0} |
| 59 | + # run: | |
| 60 | + # mkdir -p _build/html/_pdf |
| 61 | + # cp -u _build/latex/*.pdf _build/html/_pdf |
| 62 | + # TODO: download notebook support |
| 63 | + # - name: Build Download Notebooks (sphinx-tojupyter) |
| 64 | + # shell: bash -l {0} |
| 65 | + # run: | |
| 66 | + # jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going |
| 67 | + # zip -r download-notebooks.zip _build/jupyter |
| 68 | + # - uses: actions/upload-artifact@v4 |
| 69 | + # with: |
| 70 | + # name: download-notebooks |
| 71 | + # path: download-notebooks.zip |
| 72 | + # - name: Copy Download Notebooks for GH-PAGES |
| 73 | + # shell: bash -l {0} |
| 74 | + # run: | |
| 75 | + # mkdir -p _build/html/_notebooks |
| 76 | + # cp -u _build/jupyter/*.ipynb _build/html/_notebooks |
| 77 | + # Final Build of HTML (with assets) |
| 78 | + - name: Build HTML |
| 79 | + shell: bash -l {0} |
| 80 | + run: | |
| 81 | + jb build lectures --path-output ./ -n --keep-going |
| 82 | + # TODO: Re-enable -W flag once all lectures are translated and warnings are resolved |
| 83 | + # Create HTML archive for release assets |
| 84 | + - name: Create HTML archive |
| 85 | + shell: bash -l {0} |
| 86 | + run: | |
| 87 | + tar -czf lecture-python-programming-fr-html-${{ github.ref_name }}.tar.gz -C _build/html . |
| 88 | + sha256sum lecture-python-programming-fr-html-${{ github.ref_name }}.tar.gz > html-checksum.txt |
| 89 | +
|
| 90 | + # Create metadata manifest |
| 91 | + cat > html-manifest.json << EOF |
| 92 | + { |
| 93 | + "tag": "${{ github.ref_name }}", |
| 94 | + "commit": "${{ github.sha }}", |
| 95 | + "timestamp": "$(date -Iseconds)", |
| 96 | + "size_mb": $(du -sm _build/html | cut -f1), |
| 97 | + "file_count": $(find _build/html -type f | wc -l) |
| 98 | + } |
| 99 | + EOF |
| 100 | + - name: Upload archives to release |
| 101 | + uses: softprops/action-gh-release@v3 |
| 102 | + with: |
| 103 | + files: | |
| 104 | + lecture-python-programming-fr-html-${{ github.ref_name }}.tar.gz |
| 105 | + html-checksum.txt |
| 106 | + html-manifest.json |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + - name: Deploy website to gh-pages |
| 110 | + uses: peaceiris/actions-gh-pages@v4 |
| 111 | + with: |
| 112 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 113 | + publish_dir: _build/html/ |
| 114 | + # cname: python-programming-fr.quantecon.org # enable together with the _config.yml baseurl flip once DNS is decided |
| 115 | + # TODO: download notebook support |
| 116 | + # - name: Prepare lecture-python-programming.notebooks sync |
| 117 | + # shell: bash -l {0} |
| 118 | + # run: | |
| 119 | + # mkdir -p _build/lecture-python-programming.notebooks |
| 120 | + # cp -a _notebook_repo/. _build/lecture-python-programming.notebooks |
| 121 | + # cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks |
| 122 | + # ls -a _build/lecture-python-programming.notebooks |
| 123 | + # - name: Commit notebooks to lecture-python-programming.notebooks |
| 124 | + # shell: bash -l {0} |
| 125 | + # env: |
| 126 | + # QE_SERVICES_PAT: ${{ secrets.QUANTECON_SERVICES_PAT }} |
| 127 | + # run: | |
| 128 | + # git clone https://quantecon-services:$QE_SERVICES_PAT@github.com/quantecon/lecture-python-programming.notebooks |
| 129 | + |
| 130 | + # cp _build/lecture-python-programming.notebooks/*.ipynb lecture-python-programming.notebooks |
| 131 | + |
| 132 | + # cd lecture-python-programming.notebooks |
| 133 | + # git config user.name "QuantEcon Services" |
| 134 | + # git config user.email "admin@quantecon.org" |
| 135 | + # git add *.ipynb |
| 136 | + # git commit -m "auto publishing updates to notebooks" |
| 137 | + # git push origin main |
0 commit comments