Skip to content

Commit 179211b

Browse files
committed
GitHub Action
Based off Daneyon's PR: kubernetes-sigs#944
1 parent 4021279 commit 179211b

File tree

4 files changed

+91
-4
lines changed

4 files changed

+91
-4
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on:
2+
push:
3+
tags:
4+
# 1. Include all semver‐style vX.Y.Z tags
5+
- 'v*.*.*'
6+
# 2. Exclude anything with "-rc." after the patch
7+
- '!v*.*.*-rc.*'
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
version-docs:
14+
runs-on: ubuntu-latest
15+
env:
16+
VERSION: ${{ github.ref_name }} # picks up the tag, e.g. v0.3.0
17+
ALIAS: latest # your "latest" alias
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # ensures tags are available
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.x'
26+
- name: Install dependencies
27+
run: pip install mkdocs mike
28+
- name: Determine if this tag is the latest version
29+
id: is_latest
30+
run: |
31+
# Get the current tag (e.g., v0.3.0)
32+
VERSION="${{ github.ref_name }}"
33+
# Remove leading 'v' and any pre-release suffix
34+
CURRENT_BARE="${VERSION#v}"
35+
CURRENT_BARE="${CURRENT_BARE%%-*}"
36+
37+
# Find the latest semver tag (excluding pre-releases)
38+
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -v -E '\-rc\.' | head -n1)
39+
if [[ -z "$LATEST_TAG" ]]; then
40+
echo "Error: Could not find any semver-style tags."
41+
exit 1
42+
fi
43+
LATEST_BARE="${LATEST_TAG#v}"
44+
LATEST_BARE="${LATEST_BARE%%-*}"
45+
46+
# Compare
47+
if [[ "$CURRENT_BARE" == "$LATEST_BARE" ]]; then
48+
echo "is_latest=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "is_latest=false" >> $GITHUB_OUTPUT
51+
fi
52+
- name: Extract major.minor version
53+
id: extract_version
54+
run: |
55+
TAG="${{ github.ref_name }}"
56+
TAG="${TAG#v}" # Remove leading 'v'
57+
VERSION=$(echo "$TAG" | grep -oE '^[0-9]+\.[0-9]+')
58+
echo "VERSION=$VERSION" >> $GITHUB_ENV
59+
- name: Version with mike
60+
run: |
61+
if [[ "${{ steps.is_latest.outputs.is_latest }}" == "true" ]]; then
62+
mike deploy \
63+
--branch main \
64+
--push \
65+
--update-aliases $VERSION latest \
66+
site site-src
67+
mike set-default \
68+
--branch main \
69+
--push \
70+
latest site-src
71+
else
72+
mike deploy \
73+
--branch main \
74+
--push \
75+
$VERSION \
76+
site site-src
77+
fi
78+
- name: Push versioned docs
79+
run: git push origin main

hack/mkdocs/image/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ mkdocs-material==9.5.36
2323
mkdocs-material-extensions==1.3.1
2424
mkdocs-redirects==1.2.1
2525
mkdocs-mermaid2-plugin==1.1.1
26+
mike==2.1.3

mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
site_name: Kubernetes Gateway API Inference Extension
22
repo_url: https://github.com/kubernetes-sigs/gateway-api-inference-extension
33
repo_name: kubernetes-sigs/gateway-api-inference-extension
4+
site_url: 'https://gateway-api-inference-extension.sigs.k8s.io/'
45
site_dir: site
56
docs_dir: site-src
7+
extra:
8+
version:
9+
provider: mike
10+
alias: true
611
extra_css:
712
- stylesheets/extra.css
813
theme:
@@ -22,6 +27,7 @@ theme:
2227
edit_uri: edit/main/site-src/
2328
plugins:
2429
- search
30+
- mike
2531
- awesome-pages
2632
- macros:
2733
j2_line_comment_prefix: "#$"

netlify.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# netlify configuration
22
[build]
3-
publish = "site"
4-
command = "make build-docs-netlify"
5-
# available here https://github.com/netlify/build-image/blob/focal/included_software.md#languages
6-
environment = { PYTHON_VERSION = "3.8" }
3+
command = "echo 'Nothing to build, docs are pre-generated by GitHub action!'"
4+
publish = "site"
5+
6+
[context.production]
7+
branch = "main"

0 commit comments

Comments
 (0)