Skip to content

Commit 503e99a

Browse files
committed
change approach
1 parent e2c72df commit 503e99a

File tree

3 files changed

+32
-79
lines changed

3 files changed

+32
-79
lines changed

.github/workflows/gh-pages.yml

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,26 @@
1-
name: Deploy Docs
1+
name: GitHub Pages
22

33
on:
44
release:
5-
types: [created]
6-
pull_request:
7-
branches: [main]
8-
push:
9-
branches: [main]
5+
types:
6+
- created
107

118
jobs:
12-
build:
9+
job:
10+
name: GitHub Pages
1311
runs-on: ubuntu-latest
1412
steps:
1513
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
1814
- uses: actions/setup-python@v5
1915
with:
20-
python-version: "3.11"
21-
- name: Install dependencies
16+
python-version: "3.13"
17+
- name: Install project dependencies
2218
run: pip install -e ".[dev]"
23-
- name: Determine version and build type
24-
id: version
25-
run: |
26-
if [[ "${{ github.event_name }}" == "release" ]]; then
27-
echo "VERSION=stable" >> $GITHUB_OUTPUT
28-
echo "DIR=stable" >> $GITHUB_OUTPUT
29-
echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
30-
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
31-
echo "VERSION=latest" >> $GITHUB_OUTPUT
32-
echo "DIR=latest" >> $GITHUB_OUTPUT
33-
echo "TAG=main" >> $GITHUB_OUTPUT
34-
else
35-
echo "VERSION=preview" >> $GITHUB_OUTPUT
36-
echo "DIR=preview-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
37-
echo "TAG=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
38-
fi
39-
- name: Generate versions.json
40-
run: |
41-
cat <<EOF > docs/versions.json
42-
[
43-
{
44-
"version": "latest",
45-
"url": "https://xarray-contrib.github.io/xarray-dataclass/latest/",
46-
"name": "latest"
47-
},
48-
{
49-
"version": "stable",
50-
"url": "https://xarray-contrib.github.io/xarray-dataclass/stable/",
51-
"name": "stable"
52-
}
53-
]
54-
EOF
55-
- name: Build documentation
56-
env:
57-
DOCS_VERSION: ${{ steps.version.outputs.VERSION }}
58-
run: |
59-
python -m sphinx -b html docs docs/_build/${{ steps.version.outputs.DIR }}
60-
- name: Copy versions.json
61-
run: cp docs/versions.json docs/_build/${{ steps.version.outputs.DIR }}/
62-
- name: Create redirect index.html
63-
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
64-
run: |
65-
mkdir -p docs/_build
66-
cat <<EOF > docs/_build/index.html
67-
<!DOCTYPE html>
68-
<html>
69-
<head>
70-
<meta charset="UTF-8">
71-
<meta http-equiv="refresh" content="0; url=./${{ steps.version.outputs.DIR }}/">
72-
<title>Redirect to ${{ steps.version.outputs.VERSION }} documentation</title>
73-
</head>
74-
<body>
75-
<p>If you are not redirected automatically, follow this <a href="./${{ steps.version.outputs.DIR }}/">link to the ${{ steps.version.outputs.VERSION }} documentation</a>.</p>
76-
</body>
77-
</html>
78-
EOF
79-
- name: Deploy to GitHub Pages
19+
- name: Build docs
20+
run: python -m sphinx -b html docs docs/_build
21+
- name: Deploy docs
8022
uses: peaceiris/actions-gh-pages@v3
8123
with:
24+
force_orphan: true
8225
github_token: ${{ secrets.GITHUB_TOKEN }}
8326
publish_dir: ./docs/_build
84-
destination_dir: .

.github/workflows/test_docs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test documentation build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
10+
jobs:
11+
run:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: prefix-dev/[email protected]
16+
with:
17+
pixi-version: v0.49.0
18+
frozen: true
19+
- name: Test build documentation
20+
run: |
21+
pixi run -e dev gen_doc

docs/conf.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import os
21
from datetime import datetime
32

4-
# Get version from environment variable or use "dev" as fallback
5-
version = os.environ.get("DOCS_VERSION", "dev")
6-
release = version
7-
83
# Get current year for copyright
94
current_year = datetime.now().year
105

@@ -42,10 +37,6 @@
4237
"image_light": "logo-light.svg",
4338
"image_dark": "logo-dark.svg",
4439
},
45-
"switcher": {
46-
"json_url": "https://xarray-contrib.github.io/xarray-dataclass/versions.json",
47-
"version_match": version,
48-
},
4940
"github_url": "https://github.com/xarray-contrib/xarray-dataclass/",
5041
"twitter_url": "https://x.com/xarray_dev/",
5142
"show_prev_next": False,
@@ -56,7 +47,6 @@
5647
"icon": "fa-solid fa-box",
5748
},
5849
],
59-
"navbar_start": ["navbar-logo", "version-switcher"],
6050
"external_links": [
6151
{"name": "xarray", "url": "https://xarray.pydata.org/"},
6252
],

0 commit comments

Comments
 (0)