Skip to content

Commit d03c097

Browse files
authored
ci: automatically update version picker when new version published (#4765)
Signed-off-by: Neal Vaidya <[email protected]>
1 parent f315374 commit d03c097

File tree

3 files changed

+42
-76
lines changed

3 files changed

+42
-76
lines changed

.github/workflows/generate-docs.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
#
2222
# Publish:
2323
# - Main branch: publish to S3 under 'dev' (development docs)
24-
# - Tagged commits: publish to S3 under 'archive/vX.Y[.Z][suffix]' AND update 'latest' to match the release
24+
# - Tagged commits: publish to S3 under 'archive/X.Y.Z' AND update 'latest' to match the release
2525
# - Manual dispatch: publish specified version to archive (does NOT update 'latest')
2626
# - PRs: no S3 publish (only internal preview deployment if targeting release branch)
27+
# - Version manifest: automatically updated in S3 when publishing new versions (versions1.json)
2728
# - Akamai: flushes cache for the target path after publish (when DOCS_AKAMAI_ENABLED=true)
2829
#
2930
# Required Configuration:
30-
# - Repository variable: DOCS_PUBLISH_S3_TARGET_PATH (prefix under S3 bucket)
31+
# - Repository variable: DOCS_PUBLISH_S3_TARGET_PATH (prefix under S3 bucket, e.g., "dynamo")
32+
# - Repository variable: DOCS_BASE_URL (base URL for docs site, e.g., "https://docs.nvidia.com/dynamo")
3133
# - Secrets: AWS credentials (DOCS_AWS_ACCESS_KEY_ID, DOCS_AWS_SECRET_ACCESS_KEY, DOCS_AWS_S3_BUCKET, DOCS_AWS_REGION)
3234
# - Secrets: DOCS_TOKEN (GitHub PAT for PR preview deployment to external repo)
3335
# - Secrets (optional): DOCS_AWS_IAM_STS_ROLE (for OIDC authentication instead of IAM keys)
@@ -377,18 +379,42 @@ jobs:
377379
set -euo pipefail
378380
echo "Publishing version ${VERSION} to ${S3_ROOT}/${S3_PATH}/archive/${VERSION}"
379381
aws s3 sync . "${S3_ROOT}/${S3_PATH}/archive/${VERSION}" --exclude .buildinfo --exclude .doctrees --delete
382+
echo "published=true" >> "$GITHUB_OUTPUT"
380383
381-
# Copy version manifest files if they exist
382-
for file in versions.json versions1.json; do
383-
if [[ -f "${file}" ]]; then
384-
echo "Copying ${file} to ${S3_ROOT}/${S3_PATH}/"
385-
aws s3 cp "${file}" "${S3_ROOT}/${S3_PATH}/" || {
386-
echo "::warning::Failed to copy ${file} to S3"
387-
}
388-
fi
389-
done
384+
- name: Update versions manifest in S3
385+
if: ${{ steps.publish_version.outputs.published == 'true' }}
386+
env:
387+
DOCS_BASE_URL: ${{ vars.DOCS_BASE_URL }}
388+
S3_ROOT: ${{ steps.paths.outputs.s3_root }}
389+
S3_PATH: ${{ steps.paths.outputs.s3_path }}
390+
VERSION: ${{ steps.vars.outputs.version }}
391+
shell: bash
392+
run: |
393+
set -euo pipefail
390394
391-
echo "published=true" >> "$GITHUB_OUTPUT"
395+
MANIFEST_URL="${S3_ROOT}/${S3_PATH}/versions1.json"
396+
LOCAL_MANIFEST="/tmp/versions1.json"
397+
398+
# Download existing manifest from S3
399+
aws s3 cp "${MANIFEST_URL}" "${LOCAL_MANIFEST}"
400+
401+
# Check if version already exists in manifest
402+
if jq -e ".[] | select(.version == \"${VERSION}\")" "${LOCAL_MANIFEST}" > /dev/null 2>&1; then
403+
echo "Version ${VERSION} already exists in manifest, skipping update"
404+
else
405+
echo "Adding version ${VERSION} to manifest"
406+
407+
# Create new version entry and insert after "dev" and "latest" (index 2)
408+
jq --arg version "${VERSION}" \
409+
--arg url "${DOCS_BASE_URL}/archive/${VERSION}/" \
410+
'.[0:2] + [{version: $version, url: $url}] + .[2:]' \
411+
"${LOCAL_MANIFEST}" > "${LOCAL_MANIFEST}.tmp"
412+
mv "${LOCAL_MANIFEST}.tmp" "${LOCAL_MANIFEST}"
413+
414+
# Upload updated manifest to S3
415+
aws s3 cp "${LOCAL_MANIFEST}" "${MANIFEST_URL}"
416+
echo "✅ Added ${VERSION} to versions1.json"
417+
fi
392418
393419
- name: Publish latest
394420
if: ${{ steps.publish_version.outputs.published == 'true' && steps.vars.outputs.publish_to_latest == 'true' }}

docs/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
# -- Options for HTML output -------------------------------------------------
116116
html_theme = "nvidia_sphinx_theme"
117117
html_static_path = ["_static"]
118-
html_extra_path = ["project.json", "versions1.json"]
118+
html_extra_path = ["project.json"]
119119
html_theme_options = {
120120
"collapse_navigation": False,
121121
"icon_links": [
@@ -126,7 +126,9 @@
126126
}
127127
],
128128
"switcher": {
129-
"json_url": "versions1.json",
129+
# Use single shared URL so all versions see the same switcher list
130+
# When a new version is added, all old docs automatically see it
131+
"json_url": "https://docs.nvidia.com/dynamo/versions1.json",
130132
"version_match": release,
131133
},
132134
"extra_head": {

docs/versions1.json

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)