Skip to content

Commit fee9fc8

Browse files
Merge pull request #18 from tskit-dev/rename-workflow-deprecate
Rename workflow and deprecate old one
2 parents 29c2244 + af1b0bb commit fee9fc8

2 files changed

Lines changed: 109 additions & 27 deletions

File tree

.github/workflows/docs-build-template.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
# DEPRECATED - repos using this should move to the docs.yml
2+
# workflow
13
name: Documentation Build Template
24

35
on:
46
workflow_call:
57
inputs:
6-
pyproject-directory:
7-
description: 'Directory to find pyproject.toml'
8+
additional-setup:
9+
description: 'Additional setup commands to run'
810
required: false
911
type: string
10-
default: '.'
12+
default: ''
13+
make-command:
14+
description: 'Make command for C modules'
15+
required: false
16+
type: string
17+
default: ''
1118

1219
jobs:
1320
Docs:
@@ -26,40 +33,33 @@ jobs:
2633
with:
2734
python-version: '3.11'
2835

29-
- name: Install doxygen
30-
run: sudo apt-get update && sudo apt-get install -y doxygen
31-
3236
- name: Install uv
3337
uses: astral-sh/setup-uv@v6
3438
with:
3539
version: "0.8.15"
3640

3741
- name: Install doc deps
38-
run: uv sync --project=${{ inputs.pyproject-directory }} --locked --group docs
39-
40-
- name: Set build version
41-
shell: bash
4242
run: |
43-
set -euo pipefail
44-
export PROJECT_DIR="${{ inputs.pyproject-directory }}"
45-
PKG_VERSION="$(
46-
uv run --project "$PROJECT_DIR" python - <<PY
47-
import os
48-
import tomllib
49-
import pathlib
50-
import importlib.metadata as m
5143
52-
project_dir = pathlib.Path(os.environ['PROJECT_DIR'])
53-
data = tomllib.loads((project_dir / 'pyproject.toml').read_text())
54-
name = data['project']['name']
55-
print(m.version(name))
56-
PY
57-
)"
58-
echo "PKG_VERSION=$PKG_VERSION"
59-
sed -i s/__PKG_VERSION__/${PKG_VERSION}/g docs/_config.yml
44+
if [ -f pyproject.toml ]; then
45+
uv pip install --system -r pyproject.toml --extra docs
46+
elif [ -f python/pyproject.toml ]; then
47+
uv pip install --system -r python/pyproject.toml --extra docs
48+
else
49+
echo "No pyproject.toml found in root or python/ directory"
50+
exit 1
51+
fi
52+
53+
- name: Additional setup
54+
if: inputs.additional-setup != ''
55+
run: ${{ inputs.additional-setup }}
56+
57+
- name: Build C modules
58+
if: inputs.make-command != ''
59+
run: ${{ inputs.make-command }}
6060

6161
- name: Build documentation
62-
run: uv run --project=${{ inputs.pyproject-directory }} jupyter-book build -nW docs/
62+
run: cd docs && make
6363

6464
- name: Trigger tskit-site rebuild
6565
if: github.ref == 'refs/heads/main'

.github/workflows/docs.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Requires
2+
# - pyproject.toml with a group called "docs"
3+
# - docs directory in the project root
4+
# - A __PKG_VERSION__ string in the JupyterBook _config.yml which
5+
# is used to replace the with the package version derived from the
6+
# python package defined in the pyproject.toml
7+
#
8+
name: Documentation workflow for tskit-dev
9+
10+
on:
11+
workflow_call:
12+
inputs:
13+
pyproject-directory:
14+
description: 'Directory to find pyproject.toml'
15+
required: false
16+
type: string
17+
default: '.'
18+
19+
jobs:
20+
Docs:
21+
runs-on: ubuntu-24.04
22+
steps:
23+
- uses: styfle/cancel-workflow-action@0.12.1
24+
with:
25+
access_token: ${{ github.token }}
26+
27+
- uses: actions/checkout@v4.2.2
28+
with:
29+
submodules: true
30+
fetch-depth: 0
31+
32+
- uses: actions/setup-python@v5.4.0
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Install doxygen
37+
# We don't need this for every repo so could make it optional
38+
run: sudo apt-get update && sudo apt-get install -y doxygen
39+
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v6
42+
with:
43+
version: "0.8.15"
44+
45+
- name: Install doc deps
46+
run: uv sync --project=${{ inputs.pyproject-directory }} --locked --group docs
47+
48+
# This is complicated. We run an embedded python script using uv which
49+
# reads the project name from pyproject.toml, and then uses python's
50+
# importlib to determine the version number. This should be robust to
51+
# version numbers being set in a number of ways.
52+
- name: Set build version
53+
shell: bash
54+
run: |
55+
set -euo pipefail
56+
export PROJECT_DIR="${{ inputs.pyproject-directory }}"
57+
PKG_VERSION="$(
58+
uv run --project "$PROJECT_DIR" python - <<PY
59+
import os
60+
import tomllib
61+
import pathlib
62+
import importlib.metadata as m
63+
64+
project_dir = pathlib.Path(os.environ['PROJECT_DIR'])
65+
data = tomllib.loads((project_dir / 'pyproject.toml').read_text())
66+
name = data['project']['name']
67+
print(m.version(name))
68+
PY
69+
)"
70+
echo "PKG_VERSION=$PKG_VERSION"
71+
sed -i s/__PKG_VERSION__/${PKG_VERSION}/g docs/_config.yml
72+
73+
- name: Build documentation
74+
run: uv run --project=${{ inputs.pyproject-directory }} jupyter-book build -nW docs/
75+
76+
- name: Trigger tskit-site rebuild
77+
if: github.ref == 'refs/heads/main'
78+
run: |
79+
curl -X POST https://api.github.com/repos/tskit-dev/tskit-site/dispatches \
80+
-H 'Accept: application/vnd.github.everest-preview+json' \
81+
-u AdminBot-tskit:${{ secrets.ADMINBOT_TOKEN }} \
82+
--data '{"event_type":"build-docs"}'

0 commit comments

Comments
 (0)