Skip to content

Commit edd958a

Browse files
committed
docs: add versioned docs deployment with mike
Enable the mike version provider in zensical.toml and deploy docs to the gh-pages branch: main pushes publish the dev version (docs.yml), release tags publish X.Y.Z with the latest alias and root redirect (on-release-main.yml). The zensical-compatible mike fork is pinned in the dev dependency group and commit-hash locked in uv.lock
1 parent 5e9ce62 commit edd958a

5 files changed

Lines changed: 78 additions & 23 deletions

File tree

‎.github/workflows/docs.yml‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Deploys the documentation to GitHub Pages via the Pages artifact method
2-
# (repo setting: Pages source = "GitHub Actions").
3-
# NOTE: the docs-versioning phase of the migration replaces this with a
4-
# mike-based deploy to the gh-pages branch.
1+
# Deploys the documentation with mike (versioned docs on the gh-pages
2+
# branch; repo setting: Pages source = "Deploy from a branch: gh-pages").
3+
#
4+
# push to main -> version "dev"
5+
# tag vX.Y.Z -> version "X.Y.Z" + "latest" alias (on-release-main.yml)
56

67
name: Docs
78

@@ -11,38 +12,30 @@ on:
1112
workflow_dispatch:
1213

1314
permissions:
14-
contents: read
15-
pages: write
16-
id-token: write
15+
# mike commits the built site to the gh-pages branch
16+
contents: write
1717

1818
concurrency:
1919
group: pages
2020
cancel-in-progress: false
2121

2222
jobs:
2323
deploy-docs:
24-
environment:
25-
name: github-pages
26-
url: ${{ steps.deployment.outputs.page_url }}
2724
runs-on: ubuntu-latest
2825
steps:
2926
- name: Check out
3027
uses: actions/checkout@v4
3128
with:
32-
# deep clone incl. tags so hatch-vcs can derive the version
29+
# deep clone incl. tags: hatch-vcs needs them and mike needs gh-pages
3330
fetch-depth: 0
3431

3532
- name: Set up the environment
3633
uses: ./.github/actions/setup-python-env
3734

38-
- name: Build documentation
39-
run: uv run zensical build --clean
35+
- name: Configure git identity
36+
run: |
37+
git config user.name 'github-actions[bot]'
38+
git config user.email 'github-actions[bot]@users.noreply.github.com'
4039
41-
- name: Upload artifact
42-
uses: actions/upload-pages-artifact@v4
43-
with:
44-
path: site
45-
46-
- name: Deploy to GitHub Pages
47-
id: deployment
48-
uses: actions/deploy-pages@v4
40+
- name: Deploy dev documentation
41+
run: uv run mike deploy --push dev

‎.github/workflows/on-release-main.yml‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# configured on PyPI references workflow "on-release-main.yml" and
55
# environment "pypi" (no token/secret involved).
66
#
7-
# Docs are deployed from main by docs.yml; the docs-versioning phase of
8-
# the migration adds the per-release docs deploy (mike) to this workflow.
7+
# Docs: dev builds are deployed from main by docs.yml; deploy-docs below
8+
# publishes the versioned per-release docs (mike -> gh-pages branch).
99

1010
name: release-main
1111

@@ -39,3 +39,36 @@ jobs:
3939

4040
- name: Publish package
4141
run: uv publish --trusted-publishing always
42+
43+
deploy-docs:
44+
needs: publish
45+
runs-on: ubuntu-latest
46+
permissions:
47+
# mike commits the built site to the gh-pages branch
48+
contents: write
49+
concurrency:
50+
group: pages
51+
cancel-in-progress: false
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
# deep clone incl. tags: hatch-vcs needs them and mike needs gh-pages
56+
fetch-depth: 0
57+
58+
- name: Set up the environment
59+
uses: ./.github/actions/setup-python-env
60+
61+
- name: Configure git identity
62+
run: |
63+
git config user.name 'github-actions[bot]'
64+
git config user.email 'github-actions[bot]@users.noreply.github.com'
65+
66+
- name: Deploy versioned documentation
67+
env:
68+
TAG: ${{ github.ref_name }}
69+
run: |
70+
ver="${TAG#v}"
71+
# --alias-type=copy keeps /latest/ a real directory instead of a
72+
# redirect, so machine-readable files stay fetchable there
73+
uv run mike deploy --push --alias-type=copy --update-aliases "$ver" latest
74+
uv run mike set-default --push latest

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ dev = [
133133
# docs
134134
"zensical>=0.0.46",
135135
"mkdocstrings-python>=1.0.3",
136+
# docs versioning: zensical-compatible mike fork (same pin as OO-LD/oold-schema)
137+
"mike @ git+https://github.com/squidfunk/mike.git@2.2.0+zensical-0.1.0",
136138
]
137139

138140
[tool.hatch.build.targets.wheel]

‎uv.lock‎

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎zensical.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ accent = "deep orange"
6969
toggle.icon = "material/brightness-4"
7070
toggle.name = "Switch to system preference"
7171

72+
# Docs versioning: version selector fed by mike (versions.json on the
73+
# gh-pages branch). main -> dev, tag vX.Y.Z -> X.Y.Z + latest alias.
74+
[project.extra.version]
75+
provider = "mike"
76+
7277
[[project.extra.social]]
7378
icon = "fontawesome/brands/github"
7479
link = "https://github.com/OpenSemanticLab/osw-python"

0 commit comments

Comments
 (0)