-
Notifications
You must be signed in to change notification settings - Fork 19
132 lines (119 loc) · 4.47 KB
/
docbuild.yml
File metadata and controls
132 lines (119 loc) · 4.47 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
name: Documentation build
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history and tags for setuptools_scm
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install cython
python -m pip install --upgrade pip
pip install .[doc]
- name: Build docs
run: |
cd docs
SPHINXOPTS="-W" make html
- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build/html
deploy-dev:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'tee-ar-ex/trx-python'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docs
path: docs/_build/html
- name: Publish dev docs to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_build/html
target-folder: dev
deploy-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'tee-ar-ex/trx-python'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docs
path: docs/_build/html
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Fetch existing switcher.json from gh-pages
run: |
curl -sSL https://tee-ar-ex.github.io/trx-python/switcher.json -o switcher.json || echo '[]' > switcher.json
- name: Update switcher.json with new version
run: python tools/update_switcher.py switcher.json --version ${{ steps.get_version.outputs.VERSION }}
- name: Deploy all release docs in a single push
run: |
VERSION="${{ steps.get_version.outputs.VERSION }}"
# Configure git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Check out gh-pages into a temp folder
git fetch origin gh-pages
git worktree add gh-pages-out origin/gh-pages
# Update versioned folder
rm -rf "gh-pages-out/${VERSION}"
mkdir -p "gh-pages-out/${VERSION}"
cp -r docs/_build/html/. "gh-pages-out/${VERSION}/"
# Update stable folder
rm -rf gh-pages-out/stable
mkdir -p gh-pages-out/stable
cp -r docs/_build/html/. gh-pages-out/stable/
# Update switcher.json at root
cp switcher.json gh-pages-out/switcher.json
# Update root redirect index.html
cat > gh-pages-out/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>trx-python - TRX File Format for Tractography</title>
<meta name="description" content="trx-python is a Python implementation of the TRX file format for tractography data, designed for efficient handling of brain fiber tract streamlines.">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://tee-ar-ex.github.io/trx-python/stable/">
<meta http-equiv="refresh" content="0; URL=https://tee-ar-ex.github.io/trx-python/stable/">
<script>window.location.replace("https://tee-ar-ex.github.io/trx-python/stable/");</script>
</head>
<body>
<h1>trx-python Documentation</h1>
<p>Python implementation of the TRX file format for tractography data.</p>
<p>If you are not redirected automatically, visit the <a href="https://tee-ar-ex.github.io/trx-python/stable/">stable documentation</a>.</p>
</body>
</html>
EOF
# Single commit and push
cd gh-pages-out
git add --all
git diff --cached --quiet && echo "No changes to deploy." && exit 0
git commit -m "Deploy docs for ${VERSION} 🚀"
git push origin HEAD:gh-pages