-
Notifications
You must be signed in to change notification settings - Fork 169
111 lines (95 loc) · 2.98 KB
/
generate_doc.yml
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
name: Generate documentation
on:
push:
branches:
- main
tags:
- v*.*.*
pull_request:
jobs:
build-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Differentiate main from tag
run: |
if [ "${{ github.ref_name }}" != "main" ] ; then
echo "new_tag=1" >> "$GITHUB_ENV"
else
echo "new_tag=0" >> "$GITHUB_ENV"
fi
- name: Install pip packages
working-directory: docs
run: |
pip install pip --upgrade
pip install -r requirements.txt
- name: Generate test report files
working-directory: docs
run: |
python3 test_report_generator.py . ../testing_results/
- name: Build doc
working-directory: docs
run: |
python3 extract_macros.py ../ user_guide/preferences_table.rst
export ADOC_DOC_VERSION=${{ github.ref_name }}
make html SPHINXOPTS='-W --keep-going'
- name: Store the generated doc
uses: actions/upload-artifact@v4
with:
name: html
path: docs/_build/html
deploy-doc:
runs-on: ubuntu-latest
needs: build-doc
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- run: |
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
- name: Create gh-pages branch
run: >
git reset --hard ;
git clean -fdx ;
git ls-remote --exit-code --heads origin refs/heads/gh-pages &&
(
git fetch origin gh-pages ;
git checkout -b gh-pages origin/gh-pages ;
DOC_BUILDS=$(find . -mindepth 2 -name objects.inv -exec sh -c 'dirname {}' ';') ;
git rm -r . --quiet || true ;
printf "Detected doc builds: $DOC_BUILDS" ;
if ! [ -z "$DOC_BUILDS" ]; then
git checkout @ -- $DOC_BUILDS ;
fi ;
if [[ "$new_tag" == "1" ]]; then
git rm -r ${{ github.ref_name }} --quiet || true ;
fi ;
) || (
git checkout --orphan gh-pages ;
git reset --hard ;
git commit -m "initial commit" --allow-empty
)
- uses: actions/download-artifact@v4
if: ${{ env.new_tag == '0' }}
with:
name: html
- uses: actions/download-artifact@v4
if: ${{ env.new_tag == '1' }}
with:
name: html
path: ${{ github.ref_name }}
- name: Generate aux files
run: |
touch .nojekyll ;
find . -name objects.inv -exec sh -c 'dirname {}' ';' |
cut -c 3- | sort -r |
jq --raw-input . |
jq --slurp . > tags.json
- name: Commit and push to gh-pages
run: |
git add . >> /dev/null
git commit -m "deploy: ${GITHUB_SHA}" --allow-empty
git push origin gh-pages:gh-pages