Repository navigation
126 lines (104 loc) · 4.08 KB
/
Copy pathdocs.yml
File metadata and controls
126 lines (104 loc) · 4.08 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
name: Documentation
on:
pull_request:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
# Pull requests and main validate the development docs without overwriting released versions.
validate:
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install imaging system libraries for social cards
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev pngquant
- name: Install project and docs dependencies
run: uv sync --locked --group dev
- name: Build docs (strict)
env:
CI: "true"
run: uv run python -m mkdocs build --strict
- name: Check source-linked documentation
run: uv run python scripts/check_docs.py
# Only an immutable release tag publishes versioned docs.
deploy:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install imaging system libraries for social cards
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev pngquant
- name: Install project and docs dependencies
run: uv sync --locked --group dev
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Fetch existing gh-pages history
run: git fetch origin gh-pages --depth=1 || true
- name: Resolve documentation version
id: ver
run: |
VERSION=$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")
PRERELEASE=$(python -c "import re; print(str(bool(re.search(r'(?:a|b|rc|dev)[0-9]*$', '$VERSION'))).lower())")
if [ "$PRERELEASE" = "true" ]; then DOCS_VERSION="$VERSION"; else DOCS_VERSION=$(echo "$VERSION" | cut -d. -f1-2); fi
echo "full=$VERSION" >> "$GITHUB_OUTPUT"
echo "docs=$DOCS_VERSION" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
- name: Validate release tag against canonical version
run: uv run python scripts/check_versions.py --tag "${{ github.ref_name }}"
- name: Build docs preflight (strict)
env:
CI: "true"
run: uv run python -m mkdocs build --strict
- name: Check source-linked documentation
run: uv run python scripts/check_docs.py
- name: Deploy versioned docs with mike
env:
CI: "true"
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
run: |
if [ "${{ steps.ver.outputs.prerelease }}" = "true" ]; then
uv run mike deploy --push "${{ steps.ver.outputs.docs }}" --title "${{ steps.ver.outputs.full }}"
else
uv run mike deploy --push --update-aliases "${{ steps.ver.outputs.docs }}" latest \
--title "${{ steps.ver.outputs.full }}"
uv run mike set-default --push latest
fi