Skip to content

Commit 409b0a7

Browse files
authored
chore: automation for docs pre-release (opendatahub-io#563)
Basically this pr just adds the ability to update with a new release without updating the `latest` alias. Meaning we can cut docs for 3.4 but still have 3.3 be our default for now. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a prerelease option to control release vs. prerelease status and adjust docs deployment behavior. * Added a manual workflow to promote an existing release tag and update the docs "latest" alias. * **Chores** * Release workflow updated to respect prerelease semantics when publishing releases and docs. * Pinned documentation syntax-highlighting dependency to a safe version range. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent d0dc95b commit 409b0a7

File tree

5 files changed

+157
-36
lines changed

5 files changed

+157
-36
lines changed

.github/workflows/create-release.yml

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
# Usage:
1111
# 1. Go to Actions > Create Release > Run workflow
1212
# 2. Enter the tag (e.g., v1.0.0)
13-
# 3. Optionally enable "Allow overwriting existing tag" (only for pre-release iterations)
14-
# 4. Optionally enable "Create GitHub release"
13+
# 3. Optionally enable "Pre-release" to skip updating the docs 'latest' alias
14+
# 4. Optionally enable "Allow overwriting existing tag" (only for pre-release iterations)
15+
# 5. Optionally enable "Create GitHub release"
1516
#
1617
# The workflow will:
1718
# - Extract minor version (e.g., v1.0.0 -> v1.x)
@@ -30,6 +31,11 @@ on:
3031
description: 'Release tag (e.g., v1.0.0)'
3132
required: true
3233
type: string
34+
prerelease:
35+
description: 'Pre-release (will not update the docs "latest" alias)'
36+
required: false
37+
type: boolean
38+
default: false
3339
allow_tag_overwrite:
3440
description: 'Allow overwriting existing tag (use only for pre-release iterations)'
3541
required: false
@@ -58,7 +64,8 @@ jobs:
5864
version_tag: ${{ steps.set_vars.outputs.version_tag }}
5965
minor_release_branch: ${{ steps.set_vars.outputs.minor_release_branch }}
6066
minor_version: ${{ steps.set_vars.outputs.minor_version }}
61-
67+
is_prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
68+
6269
steps:
6370
- name: Checkout code
6471
uses: actions/checkout@v6
@@ -95,6 +102,11 @@ jobs:
95102
echo "Minor version: $MINOR_VERSION"
96103
echo "Release branch: $MINOR_BRANCH"
97104
105+
- name: Set unified prerelease flag
106+
id: prerelease
107+
run: |
108+
echo "is_prerelease=${{ inputs.prerelease || contains(inputs.tag, '-') || contains(inputs.tag, 'alpha') || contains(inputs.tag, 'beta') || contains(inputs.tag, 'rc') }}" >> "$GITHUB_OUTPUT"
109+
98110
- name: Validate tag format
99111
run: |
100112
TAG="${{ inputs.tag }}"
@@ -110,6 +122,7 @@ jobs:
110122
outputs:
111123
version_tag: ${{ needs.prepare-release.outputs.version_tag }}
112124
minor_release_branch: ${{ needs.prepare-release.outputs.minor_release_branch }}
125+
is_prerelease: ${{ needs.prepare-release.outputs.is_prerelease }}
113126

114127
steps:
115128
- name: Checkout code
@@ -176,6 +189,7 @@ jobs:
176189
needs: create-release-branch
177190
outputs:
178191
version_tag: ${{ needs.create-release-branch.outputs.version_tag }}
192+
is_prerelease: ${{ needs.create-release-branch.outputs.is_prerelease }}
179193

180194
steps:
181195
- name: Checkout release branch
@@ -191,13 +205,15 @@ jobs:
191205
git config user.email "${{ env.GH_USER_EMAIL }}"
192206
193207
- name: Create and push git tag
208+
env:
209+
ALLOW_TAG_OVERWRITE: ${{ inputs.allow_tag_overwrite }}
194210
run: |
195211
TAG="${{ needs.create-release-branch.outputs.version_tag }}"
196212
BRANCH="${{ needs.create-release-branch.outputs.minor_release_branch }}"
197213
198214
# Check if tag already exists
199215
if git rev-parse "$TAG" >/dev/null 2>&1; then
200-
if [ "${{ inputs.allow_tag_overwrite }}" != "true" ]; then
216+
if [ "$ALLOW_TAG_OVERWRITE" != "true" ]; then
201217
echo "❌ Error: Tag $TAG already exists!"
202218
echo ""
203219
echo "Tags should be immutable once released. To overwrite an existing tag:"
@@ -241,7 +257,7 @@ jobs:
241257
242258
> Note: Release notes can be edited after creation.
243259
draft: false
244-
prerelease: ${{ contains(inputs.tag, '-') || contains(inputs.tag, 'alpha') || contains(inputs.tag, 'beta') || contains(inputs.tag, 'rc') }}
260+
prerelease: ${{ needs.create-release-branch.outputs.is_prerelease == 'true' }}
245261

246262
build-and-push-image:
247263
name: Build and Push Image
@@ -278,22 +294,26 @@ jobs:
278294
id: build_image
279295
env:
280296
QUAY_REPO: ${{ secrets.APP_QUAY_REPO }}
297+
VERSION_TAG: ${{ needs.create-tag.outputs.version_tag }}
281298
run: |
282299
if [ -n "$QUAY_REPO" ]; then
283300
echo "Using custom repository from secret: $QUAY_REPO"
284301
echo "repo=$QUAY_REPO" >> $GITHUB_OUTPUT
285-
make build-push-image REPO="$QUAY_REPO" TAG=${{ needs.create-tag.outputs.version_tag }} CONTAINER_ENGINE=docker
302+
make build-push-image REPO="$QUAY_REPO" TAG="$VERSION_TAG" CONTAINER_ENGINE=docker
286303
else
287304
echo "Using Makefile default repository: quay.io/opendatahub/maas-api"
288305
echo "repo=quay.io/opendatahub/maas-api" >> $GITHUB_OUTPUT
289-
make build-push-image TAG=${{ needs.create-tag.outputs.version_tag }} CONTAINER_ENGINE=docker
306+
make build-push-image TAG="$VERSION_TAG" CONTAINER_ENGINE=docker
290307
fi
291308
292309
deploy-documentation:
293310
name: Deploy Documentation
294311
runs-on: ubuntu-latest
295312
needs: create-tag
296-
313+
concurrency:
314+
group: pages
315+
cancel-in-progress: false
316+
297317
steps:
298318
- name: Checkout version tag
299319
uses: actions/checkout@v6
@@ -326,13 +346,18 @@ jobs:
326346
git config --global user.email "${{ env.GH_USER_EMAIL }}"
327347
328348
- name: Deploy versioned docs with mike
349+
env:
350+
PRERELEASE: ${{ needs.create-tag.outputs.is_prerelease }}
351+
VERSION_TAG: ${{ needs.create-tag.outputs.version_tag }}
329352
run: |
330353
cd docs
331-
# Deploy the new version and update latest
332-
# Note: mike will automatically create the gh-pages branch if it doesn't exist
333-
mike deploy --push --update-aliases ${{ needs.create-tag.outputs.version_tag }} latest
334-
# Set latest as the default version
335-
mike set-default --push latest
354+
if [ "$PRERELEASE" = "true" ]; then
355+
echo "Pre-release: deploying docs version without updating 'latest' alias"
356+
mike deploy --push "$VERSION_TAG"
357+
else
358+
mike deploy --push --update-aliases "$VERSION_TAG" latest
359+
mike set-default --push latest
360+
fi
336361
337362
summary:
338363
name: Release Summary
@@ -342,27 +367,37 @@ jobs:
342367

343368
steps:
344369
- name: Summary
370+
env:
371+
VERSION_TAG: ${{ needs.create-tag.outputs.version_tag }}
372+
MINOR_BRANCH: ${{ needs.create-release-branch.outputs.minor_release_branch }}
373+
IMAGE_REPO: ${{ needs.build-and-push-image.outputs.image_repo }}
374+
IS_PRERELEASE: ${{ needs.prepare-release.outputs.is_prerelease }}
375+
CREATE_RELEASE: ${{ inputs.create_release }}
345376
run: |
346377
{
347378
echo "## Release Summary"
348379
echo ""
349-
echo "✅ **Tag**: \`${{ needs.create-tag.outputs.version_tag }}\`"
350-
echo "✅ **Release Branch**: \`${{ needs.create-release-branch.outputs.minor_release_branch }}\`"
380+
echo "✅ **Tag**: \`$VERSION_TAG\`"
381+
echo "✅ **Release Branch**: \`$MINOR_BRANCH\`"
351382
echo "✅ **Git Tag**: Created and pushed from release branch"
352-
echo "✅ **Image Built & Pushed**: \`${{ needs.build-and-push-image.outputs.image_repo }}:${{ needs.create-tag.outputs.version_tag }}\`"
353-
echo "✅ **Documentation Deployed**: \`${{ needs.create-tag.outputs.version_tag }}\`"
354-
if [ "${{ inputs.create_release }}" == "true" ]; then
383+
echo "✅ **Image Built & Pushed**: \`$IMAGE_REPO:$VERSION_TAG\`"
384+
echo "✅ **Documentation Deployed**: \`$VERSION_TAG\`"
385+
if [ "$CREATE_RELEASE" = "true" ]; then
355386
echo "✅ **GitHub Release**: Created"
356387
fi
357388
echo ""
358389
echo "### Updated Files"
359390
echo "- \`deployment/base/maas-api/kustomization.yaml\`"
360391
echo "- \`maas-api/deploy/overlays/dev/kustomization.yaml\`"
361392
echo "- \`maas-api/deploy/overlays/odh/params.env\`"
362-
echo "- MAAS_REF references updated to use \`${{ needs.create-tag.outputs.version_tag }}\`"
393+
echo "- MAAS_REF references updated to use \`$VERSION_TAG\`"
363394
echo ""
364395
echo "### Documentation"
365-
echo "- Docs Version: \`${{ needs.create-tag.outputs.version_tag }}\`"
366-
echo "- Docs Alias: \`latest\`"
396+
echo "- Docs Version: \`$VERSION_TAG\`"
397+
if [ "$IS_PRERELEASE" = "true" ]; then
398+
echo "- Docs Alias: _(not updated — pre-release)_"
399+
else
400+
echo "- Docs Alias: \`latest\`"
401+
fi
367402
echo "- Docs URL: https://opendatahub-io.github.io/models-as-a-service/"
368403
} >> "$GITHUB_STEP_SUMMARY"

.github/workflows/maas-api-ci.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,3 @@ jobs:
6969

7070
- name: Build image
7171
run: make build-image
72-
73-
- name: Login to Quay.io
74-
if: github.event_name == 'push'
75-
uses: docker/login-action@v3
76-
with:
77-
registry: quay.io
78-
username: ${{ secrets.APP_QUAY_USERNAME }}
79-
password: ${{ secrets.APP_QUAY_TOKEN }}
80-
81-
- name: Push image to Quay.io
82-
if: github.event_name == 'push'
83-
run: |
84-
make build-push-image
85-
make build-push-image -e TAG=${{ github.sha }}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Update Docs Latest Alias
2+
#
3+
# Updates the docs "latest" alias to point to an existing release tag.
4+
# The tag must already exist in the repository.
5+
#
6+
# Usage:
7+
# 1. Go to Actions > Update Docs Latest > Run workflow
8+
# 2. Enter the existing tag to promote to "latest" (e.g., v1.2.0)
9+
10+
name: Update Docs Latest
11+
run-name: Update Docs Latest → ${{ inputs.tag }}
12+
13+
on:
14+
workflow_dispatch:
15+
inputs:
16+
tag:
17+
description: 'Existing release tag to set as "latest" (e.g., v1.2.0)'
18+
required: true
19+
type: string
20+
21+
env:
22+
GH_USER_NAME: github-actions[bot]
23+
GH_USER_EMAIL: github-actions[bot]@users.noreply.github.com
24+
25+
jobs:
26+
update-latest:
27+
name: Update Latest Alias
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
concurrency:
32+
group: pages
33+
cancel-in-progress: false
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
38+
with:
39+
fetch-depth: 0
40+
fetch-tags: true
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Validate tag exists
44+
env:
45+
TAG: ${{ inputs.tag }}
46+
run: |
47+
if ! git rev-parse -- "$TAG" >/dev/null 2>&1; then
48+
echo "❌ Error: Tag '$TAG' does not exist."
49+
echo "This workflow requires an existing tag. Create a release first."
50+
exit 1
51+
fi
52+
echo "✅ Tag '$TAG' found at $(git rev-parse -- "$TAG")"
53+
54+
- name: Checkout tag
55+
env:
56+
TAG: ${{ inputs.tag }}
57+
run: git checkout --detach -- "$TAG"
58+
59+
- name: Setup Python
60+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
61+
with:
62+
python-version: '3.11'
63+
64+
- name: Cache pip dependencies
65+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
66+
with:
67+
path: ~/.cache/pip
68+
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
69+
restore-keys: |
70+
${{ runner.os }}-pip-
71+
72+
- name: Install dependencies
73+
run: pip install -r docs/requirements.txt
74+
75+
- name: Configure Git
76+
run: |
77+
git config --global user.name "${{ env.GH_USER_NAME }}"
78+
git config --global user.email "${{ env.GH_USER_EMAIL }}"
79+
80+
- name: Update latest alias
81+
env:
82+
TAG: ${{ inputs.tag }}
83+
run: |
84+
cd docs
85+
mike deploy --push --update-aliases "$TAG" latest
86+
mike set-default --push latest
87+
88+
- name: Summary
89+
env:
90+
TAG: ${{ inputs.tag }}
91+
run: |
92+
{
93+
echo "## Docs Latest Updated"
94+
echo ""
95+
echo "✅ **\`latest\`** alias now points to **\`$TAG\`**"
96+
echo ""
97+
echo "- Docs URL: https://opendatahub-io.github.io/models-as-a-service/"
98+
} >> "$GITHUB_STEP_SUMMARY"

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ When a new release tag is created using the `create-release.yml` workflow, the f
178178
- For production deployments, use a release tag: `export MAAS_REF="v1.0.0"`
179179
- For development/testing, use: `export MAAS_REF="main"`
180180

181-
This ensures that documentation and deployment scripts always reference stable release tags rather than the moving `main` branch.
181+
This ensures that documentation and deployment scripts always reference stable release tags rather than the moving `main` branch.

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
mkdocs>=1.5.0,<2.0
22
mkdocs-material>=9.0.0
3+
# Pygments 2.20 html-escapes filename; pymdownx passes filename=None for untitled blocks → AttributeError in mkdocs build
4+
pygments>=2.12,<2.20
35
mkdocs-git-revision-date-localized-plugin>=1.2.0
46
mkdocs-swagger-ui-tag>=0.7.0
57
mike>=2.0.0

0 commit comments

Comments
 (0)