-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
119 lines (105 loc) · 4.08 KB
/
docs-python.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
112
113
114
115
116
117
118
119
name: Build Python documentation
on:
pull_request:
paths:
- py-polars/docs/**
- py-polars/polars/**
- .github/workflows/docs-python.yml
push:
branches:
- main
paths:
- py-polars/docs/**
- py-polars/polars/**
- .github/workflows/docs-python.yml
repository_dispatch:
types:
- python-release
# To build older versions, specify the commit and the version
workflow_dispatch:
inputs:
polars_version:
description: 'Specify Polars version (e.g., py-0.20.1)'
required: true
git_commit:
description: 'Which commit to build'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build-python-docs:
runs-on: ubuntu-latest
steps:
- name: Parse the tag to find the major version of Polars
id: version
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
shell: bash
run: |
tag="${{ github.event.inputs.polars_version || github.event.client_payload.tag }}"
regex="py-([0-9]+)\.[0-9]+\.[0-9]+.*"
if [[ $tag =~ $regex ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
if [[ "$major" == "0" ]]; then
version="$major.$minor" # Keep "0.X" for 0.x.y versions
else
version="$major" # Use only major for 1.x.y+
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
else
echo "Error: Invalid version format. Cancelling workflow."
exit 1
fi
# Chooses the manually given commit if manually triggered.
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git_commit || github.event.client_payload.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Create virtual environment
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
- name: Install Python dependencies
working-directory: py-polars/docs
run: uv pip install -r requirements-docs.txt
- name: Build Python documentation
working-directory: py-polars/docs
env:
POLARS_VERSION: ${{ github.event.inputs.polars_version || github.event.client_payload.tag || 'main' }}
run: make html
- name: Deploy Python docs for latest release version - versioned
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: py-polars/docs/build/html
target-folder: api/python/version/${{ steps.version.outputs.version }}
single-commit: true
- name: Deploy Python docs for latest development version
if: github.event_name == 'push' && github.ref_name == 'main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: py-polars/docs/build/html
target-folder: api/python/dev
single-commit: true
- name: Deploy Python docs for latest release version - stable
if: github.event_name == 'repository_dispatch' && github.event.client_payload.is_prerelease == 'false' || (github.event_name == 'workflow_dispatch' && steps.version.outputs.version == '1')
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: py-polars/docs/build/html
target-folder: api/python/stable
single-commit: true
# Build global docs _after_ this workflow to avoid contention on the gh-pages branch
- name: Trigger global docs workflow
if: github.event_name == 'repository_dispatch'
uses: peter-evans/repository-dispatch@v3
with:
event-type: python-release-docs
client-payload: >
{
"sha": "${{ github.event.client_payload.sha }}"
}