Skip to content

Commit a446346

Browse files
mmckyclaude
andcommitted
Set up GitHub Pages publishing (cache + publish workflows, environment)
Mirrors the fa edition's publishing machinery, adapted for fr: - environment.yml copied from the English source (anaconda 2026.06, quantecon-book-theme 0.21.0) so the build matches the seeded content - cache.yml builds the execution cache on every push to main - publish.yml builds HTML on publish* tags, uploads a release archive, and deploys to gh-pages (custom-domain CNAME left commented pending the DNS decision); -W disabled for the first publishes, as in cache.yml - _config.yml now points at this repo and its actual serving URL (quantecon.github.io/lecture-python-programming.fr) instead of the English site, avoiding the baseurl/CNAME mismatch found on fa and zh-cn; also sets Sphinx language: fr Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e641d96 commit a446346

4 files changed

Lines changed: 199 additions & 6 deletions

File tree

.github/workflows/cache.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build Cache [using jupyter-book]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
cache:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
- name: Setup Anaconda
12+
uses: conda-incubator/setup-miniconda@v4
13+
with:
14+
auto-update-conda: true
15+
auto-activate-base: true
16+
miniconda-version: 'latest'
17+
python-version: "3.13"
18+
environment-file: environment.yml
19+
activate-environment: quantecon
20+
- name: Build HTML
21+
shell: bash -l {0}
22+
run: |
23+
jb build lectures --path-output ./ --keep-going
24+
# TODO: Re-enable -W flag once all lectures are translated and warnings are resolved
25+
- name: Upload Execution Reports
26+
uses: actions/upload-artifact@v7
27+
if: failure()
28+
with:
29+
name: execution-reports
30+
path: _build/html/reports
31+
- name: Upload "_build" folder (cache)
32+
uses: actions/upload-artifact@v7
33+
with:
34+
name: build-cache
35+
path: _build
36+
include-hidden-files: true

.github/workflows/publish.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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

environment.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: quantecon
2+
channels:
3+
- default
4+
dependencies:
5+
- python=3.13
6+
- anaconda=2026.06
7+
- pip
8+
- pip:
9+
- jupyter-book>=1.0.4post1,<2.0
10+
- quantecon-book-theme==0.21.0
11+
- sphinx-tojupyter==0.6.0
12+
- sphinxext-rediraffe==0.3.0
13+
- sphinx-exercise==1.2.1
14+
- sphinxcontrib-youtube==1.5.0
15+
- sphinx-togglebutton==0.4.5
16+
17+

lectures/_config.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ execute:
88
timeout: 600 # 10 minutes
99

1010
html:
11-
baseurl: https://python-programming.quantecon.org/
11+
# TODO: flip to https://python-programming-fr.quantecon.org/ together with the
12+
# publish.yml cname once the custom-domain DNS is set up
13+
baseurl: https://quantecon.github.io/lecture-python-programming.fr/
1214

1315
latex:
1416
latex_documents:
15-
targetname: quantecon-python-programming.tex
17+
targetname: quantecon-python-programming-fr.tex
1618

1719
sphinx:
1820
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinx_exercise, sphinx_togglebutton, sphinx.ext.intersphinx]
1921
config:
22+
language: fr
2023
# bibtex_reference_style: author_year #TODO: enable if bibtex bibliography is used in series
2124
# false-positive links
2225
linkcheck_ignore: ['https://github.com/matplotlib/matplotlib/blob/v3.6.2/lib/matplotlib/axes/_axes.py#L1417-L1669',
@@ -43,8 +46,8 @@ sphinx:
4346
dark_logo: quantecon-logo-transparent.png
4447
header_organisation_url: https://quantecon.org
4548
header_organisation: QuantEcon
46-
repository_url: https://github.com/QuantEcon/lecture-python-programming
47-
nb_repository_url: https://github.com/QuantEcon/lecture-python-programming.notebooks
49+
repository_url: https://github.com/QuantEcon/lecture-python-programming.fr
50+
nb_repository_url: https://github.com/QuantEcon/lecture-python-programming.fr.notebooks
4851
path_to_docs: lectures
4952
twitter: quantecon
5053
twitter_logo_url: https://assets.quantecon.org/img/qe-twitter-logo.png
@@ -67,8 +70,8 @@ sphinx:
6770
index_toc.md: intro.md
6871
tojupyter_static_file_path: ["source/_static", "_static"]
6972
tojupyter_target_html: true
70-
tojupyter_urlpath: "https://python-programming.quantecon.org/"
71-
tojupyter_image_urlpath: "https://python-programming.quantecon.org/_static/"
73+
tojupyter_urlpath: "https://quantecon.github.io/lecture-python-programming.fr/"
74+
tojupyter_image_urlpath: "https://quantecon.github.io/lecture-python-programming.fr/_static/"
7275
tojupyter_lang_synonyms: ["ipython", "ipython3", "python"]
7376
tojupyter_kernels:
7477
python3:

0 commit comments

Comments
 (0)