Repository navigation
89 lines (78 loc) · 3.34 KB
/
Copy pathdocs.yml
File metadata and controls
89 lines (78 loc) · 3.34 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
name: Build and deploy documentation
permissions:
contents: write
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
# 1. Checkout the repository
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
# 2. Set up Python
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
# 3. Install Sphinx and dependencies
- name: Install Sphinx and dependencies
run: pip install -r docs/requirements.txt
# 4. Build the HTML documentation (warnings are fatal)
- name: Generate Sphinx docs
run: sphinx-build -W --keep-going -b html docs docs/_build/html
# 4b. Build the PDF and ship it inside the HTML tree, so it lands in the
# versioned directory (/vX.Y/cryptnox-id-cli.pdf) on deploy — the
# index page's "Download as PDF" link and the docs hub point there.
- name: Install LaTeX for PDF
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
latexmk texlive-latex-recommended texlive-latex-extra \
texlive-fonts-recommended texlive-fonts-extra tex-gyre
- name: Build PDF (pdflatex)
run: |
sphinx-build -M latexpdf docs docs/_build
cp docs/_build/latex/cryptnox-id-cli.pdf docs/_build/html/cryptnox-id-cli.pdf
# 5. Fetch what is currently published, to carry earlier versions over
# (continue-on-error: the branch does not exist on the very first deploy)
- name: Fetch previously published versions
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
continue-on-error: true
with:
ref: gh-pages
path: gh-pages-prev
# 6. Assemble the versioned site, like docs.cryptnox.com/cryptnox-hardware-wallet:
# this build under /vMAJ.MIN/ (docs_version in docs/conf.py), earlier
# /v*/ trees kept as published, and the site root redirecting to the
# version being built.
- name: Assemble versioned site
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
SLUG=$(python -c 'import runpy; print(runpy.run_path("docs/conf.py")["docs_version"])')
rm -rf docs/_site
mkdir -p docs/_site
for d in gh-pages-prev/v*/ ; do
[ -d "$d" ] && cp -R "$d" "docs/_site/$(basename "$d")"
done
rm -rf "docs/_site/$SLUG"
cp -R docs/_build/html "docs/_site/$SLUG"
printf '<meta http-equiv="refresh" content="0; url=./%s/">\n' "$SLUG" > docs/_site/index.html
# 7. Deploy to GitHub Pages (only on push to main)
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
publish_branch: gh-pages
allow_empty_commit: false
keep_files: false
force_orphan: false
enable_jekyll: false