Skip to content

Commit 9427542

Browse files
search5claude
andcommitted
Add versioned docs to GitHub Pages
- Build docs for every release tag (v0.9.9+) into /v{tag}/ subdirectory - Build latest docs from master into /latest/ - Generate root index.html with version list - Triggered on master push and tag push Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e02a3e commit 9427542

1 file changed

Lines changed: 63 additions & 4 deletions

File tree

.github/workflows/docs.yml

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Deploy Sphinx docs to GitHub Pages
33
on:
44
push:
55
branches: [master]
6+
tags: ['v*']
67
workflow_dispatch:
78

89
permissions:
@@ -19,23 +20,81 @@ jobs:
1920
runs-on: ubuntu-latest
2021
steps:
2122
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
2225

2326
- uses: actions/setup-python@v5
2427
with:
2528
python-version: "3.12"
2629

2730
- name: Install dependencies
31+
run: pip install sphinx sphinx-rtd-theme
32+
33+
- name: Build latest docs from master
34+
run: |
35+
mkdir -p _site/latest
36+
sphinx-build -b html docs _site/latest
37+
38+
- name: Build docs for each release tag
2839
run: |
29-
pip install sphinx sphinx-rtd-theme
40+
for tag in $(git tag --list 'v*' --sort=-version:refname); do
41+
echo "Building docs for $tag"
42+
git checkout "$tag" -- docs/ solr/ 2>/dev/null || continue
43+
version_dir="_site/${tag}"
44+
mkdir -p "$version_dir"
45+
sphinx-build -b html docs "$version_dir" 2>/dev/null || echo " Skipped $tag (build failed)"
46+
git checkout master -- docs/ solr/ 2>/dev/null
47+
done
3048
31-
- name: Build Sphinx docs
49+
- name: Generate version index page
3250
run: |
33-
sphinx-build -b html docs docs/_build
51+
LATEST_TAG=$(git tag --list 'v*' --sort=-version:refname | head -1)
52+
cat > _site/index.html << 'HEADER'
53+
<!DOCTYPE html>
54+
<html>
55+
<head>
56+
<meta charset="utf-8">
57+
<title>solrpy Documentation</title>
58+
<style>
59+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 700px; margin: 60px auto; padding: 0 20px; color: #333; }
60+
h1 { border-bottom: 2px solid #2980b9; padding-bottom: 10px; }
61+
a { color: #2980b9; text-decoration: none; }
62+
a:hover { text-decoration: underline; }
63+
ul { list-style: none; padding: 0; }
64+
li { padding: 8px 0; border-bottom: 1px solid #eee; }
65+
.latest { font-weight: bold; }
66+
.badge { background: #2980b9; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; margin-left: 8px; }
67+
</style>
68+
</head>
69+
<body>
70+
<h1>solrpy Documentation</h1>
71+
<p><a href="latest/">Latest (master)</a></p>
72+
<h2>Versions</h2>
73+
<ul>
74+
HEADER
75+
76+
for tag in $(git tag --list 'v*' --sort=-version:refname); do
77+
if [ -d "_site/${tag}" ]; then
78+
badge=""
79+
if [ "$tag" = "$LATEST_TAG" ]; then
80+
badge='<span class="badge">latest release</span>'
81+
fi
82+
echo " <li><a href=\"${tag}/\">${tag}</a>${badge}</li>" >> _site/index.html
83+
fi
84+
done
85+
86+
cat >> _site/index.html << 'FOOTER'
87+
</ul>
88+
<hr>
89+
<p><a href="https://github.com/search5/solrpy">GitHub</a> · <a href="https://pypi.org/project/solrpy/">PyPI</a></p>
90+
</body>
91+
</html>
92+
FOOTER
3493
3594
- name: Upload artifact
3695
uses: actions/upload-pages-artifact@v3
3796
with:
38-
path: docs/_build
97+
path: _site
3998

4099
deploy:
41100
environment:

0 commit comments

Comments
 (0)