Skip to content

Commit 29684ce

Browse files
authored
Publish python docs on ci (#104)
1 parent da0cd83 commit 29684ce

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

.github/workflows/python-docs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Publish Python docs
2+
3+
# Only run on new tags starting with `py-v`
4+
on:
5+
push:
6+
tags:
7+
- "py-v*"
8+
workflow_dispatch:
9+
10+
# https://stackoverflow.com/a/77412363
11+
permissions:
12+
contents: write
13+
pages: write
14+
15+
jobs:
16+
build:
17+
name: Deploy Python docs
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
# We need to additionally fetch the gh-pages branch for mike deploy
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- uses: Swatinem/rust-cache@v2
29+
30+
- name: Install a specific version of uv
31+
uses: astral-sh/setup-uv@v5
32+
with:
33+
enable-cache: true
34+
version: "0.5.x"
35+
36+
- name: Set up Python 3.11
37+
run: uv python install 3.11
38+
39+
- name: Install dependencies
40+
run: uv sync --project python --no-install-package geoindex-rs
41+
42+
- name: Build python packages
43+
run: |
44+
cd python && uv run --no-project maturin develop && cd ..
45+
46+
- name: Deploy docs
47+
env:
48+
GIT_COMMITTER_NAME: CI
49+
GIT_COMMITTER_EMAIL: [email protected]
50+
run: |
51+
# Get most recent git tag
52+
# https://stackoverflow.com/a/7261049
53+
# https://stackoverflow.com/a/3867811
54+
# We don't use {{github.ref_name}} because if triggered manually, it
55+
# will be a branch name instead of a tag version.
56+
# Then remove `py-` from the tag
57+
VERSION=$(git describe --tags --match="py-*" --abbrev=0 | cut -c 4-)
58+
59+
# Only push publish docs as latest version if no letters in git tag
60+
# after the first character
61+
# (usually the git tag will have v as the first character)
62+
# Note the `cut` index is 1-ordered
63+
if echo $VERSION | cut -c 2- | grep -q "[A-Za-z]"; then
64+
cd python && uv run --no-project mike deploy $VERSION latest --update-aliases --push
65+
else
66+
# For beta versions publish but don't set as latest
67+
cd python && uv run --no-project mike deploy $VERSION --update-aliases --push
68+
fi

python/mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ theme:
4040

4141
# Palette toggle for light mode
4242
- media: "(prefers-color-scheme: light)"
43-
primary: default
43+
primary: blue grey
4444
accent: deep orange
4545
toggle:
4646
icon: material/brightness-7
@@ -49,7 +49,7 @@ theme:
4949
# Palette toggle for dark mode
5050
- media: "(prefers-color-scheme: dark)"
5151
scheme: slate
52-
primary: default
52+
primary: blue grey
5353
accent: deep orange
5454
toggle:
5555
icon: material/brightness-4

0 commit comments

Comments
 (0)