-
Notifications
You must be signed in to change notification settings - Fork 4
74 lines (64 loc) · 2.02 KB
/
docs.yaml
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
name: docs
on:
pull_request:
push:
branches: [ main ]
tags:
- '*'
jobs:
build-docs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
# Fetch the history for all tags and branches
# so that the correct version string can be constructed
# by setuptools_scm.
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: install dependencies
run: |
python -m pip install \
-r requirements/minimal.txt \
-r requirements/docs.txt \
build \
packaging
- name: generate version string
run: python -m build --sdist
- name: build Docs
run: make -C docs
- name: move docs
if: github.event_name == 'push'
run: |
cp docs/is_new_stable.py /tmp/
mv docs/_build/html /tmp/${GITHUB_REF_NAME}
git checkout gh-pages
rm -fr ${GITHUB_REF_NAME}
mv /tmp/${GITHUB_REF_NAME} .
find ${GITHUB_REF_NAME} -name __pycache__ -exec rm -r {} +
rm -fr latest
ln -s ${GITHUB_REF_NAME} latest
- name: check if tag is new stable
if: github.event_name == 'push' && github.ref_type == 'tag'
run: |
if [ -f stable ]; then
export STABLE=$(readlink stable)
else
export STABLE=0
fi
if python /tmp/is_new_stable.py ${STABLE} ${GITHUB_REF_NAME}; then
# Use for "stable" docs path.
echo "new stable is ${GITHUB_REF_NAME}"
rm -fr stable
ln -s ${GITHUB_REF_NAME} stable
echo "STABLE_PATH=stable" >> $GITHUB_ENV
fi
- name: commit to gh-pages
if: github.event_name == 'push'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: deploy ${{ github.ref }}
branch: gh-pages
file_pattern: ${{ github.ref_name }} latest ${{ env.STABLE_PATH }}