-
Notifications
You must be signed in to change notification settings - Fork 14
160 lines (148 loc) · 6.25 KB
/
documentation.yaml
File metadata and controls
160 lines (148 loc) · 6.25 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: pypop.org website and docs generation
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
paths: &docs_paths
- '*.rst'
- 'NEWS.md'
- 'LICENSE'
- 'pypop-logo.png'
- 'website/**'
- 'src/PyPop/**'
- 'tests/data/doc-examples/**'
- 'src/script_build/generate_metadata.py'
- '.github/workflows/documentation.yaml'
- '!website/_templates/announcement_banner.html'
- '!website/README.md'
- '!website/reference/**'
pull_request:
paths: *docs_paths
release:
types:
- published
permissions:
contents: write
jobs:
docs_check:
runs-on: ubuntu-latest
outputs:
docs_rebuild: ${{ steps.changes.outputs.docs_rebuild }}
steps:
- name: Checkout full repo history
uses: actions/checkout@v6
with:
fetch-depth: 0 # fetch full history so we can diff branches
- name: Detect changed files
id: changes
run: |
set -x
git diff --name-only 'HEAD^'
changed_files=$(git diff --name-only HEAD^)
# Skip rebuild only if there are changes and all are under src/PyPop/
if [[ "${GITHUB_REF}" == "refs/heads/main" ]] && [[ -n "$changed_files" ]] && \
! echo "$changed_files" | grep -qv '^src/PyPop/'; then
echo "Skipping docs rebuild!"
echo "docs_rebuild=false" >> "$GITHUB_OUTPUT"
else
echo "Doing docs rebuild!"
echo "docs_rebuild=true" >> "$GITHUB_OUTPUT"
fi
docs:
runs-on: ubuntu-latest
needs: docs_check
if: needs.docs_check.outputs.docs_rebuild == 'true'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check GitHub Action permissions
run: |
echo "github.actor: ${{ toJson(github.actor) }}"
echo "github.triggering_actor: ${{ toJson(github.triggering_actor) }}"
echo "github.repository_owner: ${{ toJson(github.repository_owner) }}"
echo "github.repository_owner: ${{ toJson(github.repository_owner) }}"
echo "github.repository: ${{ toJson(github.repository) }}"
echo "github.event.pull_request.base.repo.full_name: ${{ toJson(github.event.pull_request.base.repo.full_name) }}"
echo "github.event.pull_request.head.repo.full_name: ${{ toJson(github.event.pull_request.head.repo.full_name) }}"
echo "github.ref: ${{ toJson(github.ref) }}"
echo "github.event_name: ${{ toJson(github.event_name) }}"
echo "github.event.action: ${{ toJson(github.event.action) }}"
echo "github.event.release.target_commitish: ${{ toJson(github.event.release.target_commitish) }}"
- uses: actions/setup-python@v6
- name: Install Python deps + graphviz for API diagrams
run: |
# shared dependencies
pip install -r website/requirements-docs.txt
sudo apt-get install -y --no-install-recommends graphviz
- name: Determine AutoAPI source + version metadata
id: select-autoapi
run: |
mode="internal"
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "Detected main branch (non-release): using installed package"
mode="installed"
echo "PYPOP_DOCS_MODE=$mode" >> "$GITHUB_ENV"
pip install pypop-genomics[test] # only needed in this mode
# test current user guide again released API
sphinx-build -b doctest website/doctest/ _doctests
else
echo "Using internal source (tag or branch build)"
echo "PYPOP_DOCS_MODE=$mode" >> "$GITHUB_ENV"
# needed because tomli is used for backwards compatibility
pip install tomli
# in the internal case we generate _metadata.py manually
# since we are not doing a `pip install` build
python src/script_build/generate_metadata.py src/PyPop/_metadata.py
fi
- name: Build LaTeX sources
run: |
# latex build in separate directory
# it generates a lot of files we don't need to keep
sphinx-build -b latex website _latexbuild
# Compile PDF (auto-detects the versioned .tex file)
- name: Compile PDF
uses: xu-cheng/latex-action@v4
with:
working_directory: _latexbuild
root_file: |
pypop-guide-*.tex
pypop-api-*.tex
docker_image: ghcr.io/xu-cheng/texlive-debian:20250701
- name: Postprocess PDF
run: |
# create _build directory and move the PDFs there
mkdir _build
cp _latexbuild/pypop-*.pdf _build/
# create a symlink from 'pypop-guide.pdf' to the latest version
cd _build/
ln -s pypop-guide*.pdf pypop-guide.pdf
ln -s pypop-api*.pdf pypop-api.pdf
cd -
- name: Build HTML
run: |
# now build the HTML
sphinx-build website _build
- name: Deploy to beta site
uses: peaceiris/actions-gh-pages@v4.1.0
# only update beta site if base and head branches match, not for forks
# forks cannot access secrets to deploy, see: https://github.com/orgs/community/discussions/26829
# also dependabot jobs won't work either
if: ${{ (github.event.pull_request.base.repo.full_name == github.event.pull_request.head.repo.full_name) && github.actor != 'dependabot[bot]' }}
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: alexlancaster/beta.pypop.org
publish_branch: gh-pages # default: gh-pages
publish_dir: _build/
force_orphan: true
- name: Deploy to production
uses: peaceiris/actions-gh-pages@v4
# only update on either a push on main, or published release on the main
if: ${{ (github.ref == 'refs/heads/main' && github.event_name == 'push') || (github.event.release.target_commitish == 'main' && github.event_name == 'release' && github.event.action == 'published') }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true