Skip to content

Commit c30e5c8

Browse files
make examples available via github pages on release (#128)
* remove useless test * add infra to upload examples * test example upload scripts * add scripts, oops
1 parent 9fc80a2 commit c30e5c8

30 files changed

Lines changed: 1850 additions & 307 deletions

‎.github/workflows/ci.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ jobs:
161161
id-token: write
162162
# This permission allows writing releases
163163
contents: write
164+
# This permission allows starting the docs workflow (last step)
165+
actions: write
164166

165167
steps:
166168
- uses: actions/checkout@v7
@@ -186,3 +188,29 @@ jobs:
186188
with:
187189
generate_release_notes: true
188190
files: './dist/*'
191+
192+
# The docs workflow publishes the example scripts of each release,
193+
# pinned to that release, and leaves out a version that is not on PyPI
194+
# (see plans/examples-distribution-v2.md). So wait until this one is
195+
# there before starting it. The version is read from the sdist's name,
196+
# which is the form PyPI knows it by (tag v0.1.0-rc1 is 0.1.0rc1).
197+
- name: Wait for the release on PyPI
198+
run: |
199+
sdist=$(basename dist/cellier-*.tar.gz .tar.gz)
200+
version="${sdist#cellier-}"
201+
for _ in $(seq 30); do
202+
if curl -fsS -o /dev/null "https://pypi.org/pypi/cellier/${version}/json"; then
203+
echo "cellier ${version} is on PyPI"
204+
exit 0
205+
fi
206+
sleep 10
207+
done
208+
echo "cellier ${version} did not appear on PyPI" >&2
209+
exit 1
210+
211+
# The site can only be deployed from main, so the docs workflow is
212+
# started there rather than run on this tag.
213+
- name: Rebuild the docs site with this release's examples
214+
env:
215+
GH_TOKEN: ${{ github.token }}
216+
run: gh workflow run docs.yml --repo "${{ github.repository }}" --ref main

‎.github/workflows/docs.yml‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
name: Documentation
22

3+
# Builds the docs and adds the example scripts of every release, pinned to
4+
# that release (see plans/examples-distribution-v2.md). The whole site is
5+
# rebuilt on each run, so nothing is kept from the previous deploy.
6+
#
7+
# workflow_dispatch is how the release job in ci.yml starts this after a new
8+
# version is on PyPI.
9+
310
on:
411
push:
512
branches:
6-
- master
713
- main
814
pull_request:
15+
workflow_dispatch:
916

1017
permissions:
1118
contents: read
@@ -16,7 +23,10 @@ jobs:
1623
build:
1724
runs-on: ubuntu-latest
1825
steps:
26+
# Full history, so the release tags are there to read the examples from.
1927
- uses: actions/checkout@v7
28+
with:
29+
fetch-depth: 0
2030
- uses: actions/configure-pages@v6
2131
- uses: actions/setup-python@v7
2232
with:
@@ -26,14 +36,26 @@ jobs:
2636
- run: pip install mkdocstrings mkdocstrings-python "griffe-pydantic>=1.3.1"
2737
- run: zensical build --clean
2838

39+
# Writes site/<tag>/examples/ and site/latest/examples/. On a pull
40+
# request it also fails if an example in the branch could not be pinned.
41+
- run: pip install packaging
42+
- name: Add the released examples
43+
run: >-
44+
python scripts/example_upload/assemble_example_site.py site
45+
${{ github.event_name == 'pull_request' && '--working-tree-version 0.0.0' || '' }}
46+
2947
- uses: actions/upload-pages-artifact@v5
3048
with:
3149
path: site
3250

3351
deploy:
34-
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
52+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
3553
needs: build
3654
runs-on: ubuntu-latest
55+
# One deploy at a time; a deploy that has started is left to finish.
56+
concurrency:
57+
group: pages
58+
cancel-in-progress: false
3759
environment:
3860
name: github-pages
3961
url: ${{ steps.deployment.outputs.page_url }}

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ examples = [
101101
dev-all = ["cellier[dev,test,pyside,examples,logging,remote,anywidget,graph]"]
102102

103103
[project.urls]
104-
homepage = "https://github.com/kevinyamauchi/cellier"
105-
repository = "https://github.com/kevinyamauchi/cellier"
104+
homepage = "https://github.com/cellcanvas/cellier"
105+
repository = "https://github.com/cellcanvas/cellier"
106106

107107
# Entry points
108108
# https://peps.python.org/pep-0621/#entry-points

0 commit comments

Comments
 (0)