-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.36 KB
/
api-docs.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
# Trigger this workflow manually while choosing a tag in order update the API docs.
#
# This is going to:
# - Build the API docs
# - Deploy to GH pages
#
# The target folder for deploying docs in GH pages is:
# - If it is a devrelease tag: The tag itself.
# - Otherwise: The major version, as in the Python project metadata.
#
# If the `latest` option is selected, the docs are also deployed to the latest folder.
#
# Tip: If you need to update the docs for a certain major version without making a new release, just create
# a new tag manually while adding a "-n" suffix to the previous tag (e.g.: x.y.z-1, x.y.z-2, etc).
#
name: "API Docs"
on:
workflow_dispatch:
inputs:
latest:
type: boolean
default: false
required: false
description: Latest
env:
DEVRELEASE_PATTERN: ^\d+\.\d+\.\d+-dev\d+$ # Match any tags like '1.2.3-dev123'
jobs:
api-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Cache UV
uses: actions/cache@v3
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install project
run: make install-project
- name: Render API docs
run: make api-docs
- name: Get docs version
id: get-docs-version
run: |
if ! [[ -z $(echo "${GITHUB_REF#refs/tags/}" | grep -xP '${{ env.DEVRELEASE_PATTERN }}') ]] ; then
echo "value=v${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "value=v$(uvx --from commitizen cz version -p | grep -oP '^\d+')" >> $GITHUB_OUTPUT
fi
- name: Publish API docs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs/api/_build/html
target-folder: docs/api/${{ steps.get-docs-version.outputs.value }}
- name: Publish API docs to GitHub Pages (latest)
if: ${{ github.event.inputs.latest != 'false' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs/api/_build/html
target-folder: docs/api/latest