-
Notifications
You must be signed in to change notification settings - Fork 9
185 lines (160 loc) · 5.42 KB
/
docs.yaml
File metadata and controls
185 lines (160 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Docs
on:
push:
branches: [main]
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'flixopt/**'
pull_request:
paths:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:
inputs:
deploy:
description: 'Deploy docs to GitHub Pages'
type: boolean
default: false
version:
description: 'Version to deploy (e.g., v6.0.0)'
type: string
required: false
workflow_call:
inputs:
deploy:
type: boolean
default: false
version:
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
MPLBACKEND: Agg
PLOTLY_RENDERER: notebook_connected
jobs:
build:
name: Build documentation
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.10.9"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v5
id: notebook-cache
with:
path: docs/notebooks/**/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute fast notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute fast notebooks in parallel (4 at a time), excluding slow ones
cd docs/notebooks && find . -name '*.ipynb' | \
grep -vFf slow_notebooks.txt | \
xargs -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Build docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: mkdocs build --strict
- uses: actions/upload-artifact@v4
with:
name: docs
path: site/
retention-days: 7
deploy:
name: Deploy documentation
needs: build
if: ${{ inputs.deploy == true && inputs.version != '' }}
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.10.9"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v5
id: notebook-cache
with:
path: docs/notebooks/**/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute fast notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute fast notebooks in parallel (4 at a time), excluding slow ones
cd docs/notebooks && find . -name '*.ipynb' | \
grep -vFf slow_notebooks.txt | \
xargs -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Execute slow notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute slow notebooks (only on release)
cd docs/notebooks && cat slow_notebooks.txt | \
xargs -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Deploy docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: |
VERSION=${{ inputs.version }}
VERSION=${VERSION#v}
# Check if this is a pre-release (alpha, beta, rc)
if [[ "$VERSION" =~ (alpha|beta|rc) ]]; then
# Pre-release: deploy version only, don't update "latest"
mike deploy --push $VERSION
else
# Stable release: deploy and update "latest" alias
mike deploy --push --update-aliases $VERSION latest
mike set-default --push latest
fi