Skip to content

feat(ci): automate Fern version registration and harden publish workflow#1290

Merged
lalitadithya merged 2 commits into
NVIDIA:mainfrom
pdmack:pdmack/fern-publish-auto-version
May 15, 2026
Merged

feat(ci): automate Fern version registration and harden publish workflow#1290
lalitadithya merged 2 commits into
NVIDIA:mainfrom
pdmack:pdmack/fern-publish-auto-version

Conversation

@pdmack

@pdmack pdmack commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Automate Fern version registration on docs/vX.Y.Z tag push and harden the publish workflow. Pattern ported from NVIDIA/topograph (PRs #325, #327, #329, #330).

On tag push the workflow now:

  1. Generates fern/versions/vX.Y.Z.yml from the tag's docs/index.yml
  2. Adds a version entry to fern/docs.yml via yq
  3. Commits both back to main so future publishes include the new version

Also:

  • Hardens frozen version checkout (glob guard, warning not error, MDX img self-closing fix)
  • Switches version stamping from sed to yq
  • Bumps permissions to contents: write for the commit-back step
  • Adds MDX img fix to preview-build frozen checkout for consistency

Fixes #1289

Type of Change

  • ✨ New feature
  • 🔨 Build/CI

Component(s) Affected

  • Documentation/CI

Testing

  • Manual testing completed
  • No breaking changes (or documented)

Checklist

  • Self-review completed
  • Ready for review

Summary by CodeRabbit

  • Chores
    • Enhanced docs publishing workflow with improved version generation and automated updates for tagged releases.
    • Applied self-closing to archived image tags so older documentation renders correctly across versions.
    • Made frozen-content checkout tolerant of missing tags and moved latest-version stamping to a safer YAML-based update.

Review Change Stack

On docs/vX.Y.Z tag push, the publish workflow now:
1. Generates fern/versions/vX.Y.Z.yml from the tag's docs/index.yml
2. Adds a version entry to fern/docs.yml via yq
3. Commits both back to main for future publishes

Also hardens frozen version checkout (guard, warning not error,
MDX img self-closing fix) and switches version stamping from sed to yq.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR automates Fern version artifact generation on docs/v* tag pushes and hardens frozen version checkout. The publish workflow now creates and commits version YAML files from tagged docs/index.yml entries, updates fern/docs.yml using yq, and gracefully handles missing tags with warnings. The preview build applies an MDX fix to self-close <img> tags in archived content.

Changes

Fern Version Automation and Frozen Version Hardening

Layer / File(s) Summary
Workflow infrastructure and permissions
.github/workflows/publish-fern-docs.yml
Documentation block updated to describe new version artifact automation, and permissions.contents changed from read to write to enable committing generated files back to main.
Automated version generation on tag push
.github/workflows/publish-fern-docs.yml
New tag-triggered steps extract docs/index.yml from the pushed tag, generate a versioned fern/versions/<tag>.yml, and guard against existing or missing tags while logging progress.
Insert version and commit changes
.github/workflows/publish-fern-docs.yml
Appends the new version entry to fern/docs.yml with yq, checks for diffs, and commits/pushes fern/versions/ and fern/docs.yml to main when changes exist.
Hardened frozen version checkout and MDX fix
.github/workflows/publish-fern-docs.yml, .github/workflows/fern-docs-preview-build.yml
Missing tags now log a warning and skip checkout instead of failing; preview build adds a step to rewrite non-self-closing <img ...> tags into <img ... /> inside extracted *.md files for MDX compatibility.
Latest version stamping with yq
.github/workflows/publish-fern-docs.yml
Replaces sed-based stamping with a yq update that sets the display-name for slug latest to include the latest version and then reads back the value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • lalitadithya

Poem

🐰 A hop, a patch, the docs align,

Tags now spawn their version sign.
yq stamps latest with tidy grace,
Archived imgs now find their place —
Pipelines hum, the rabbit cheers!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main changes: automating Fern version registration and hardening the publish workflow, which align with the primary objectives.
Linked Issues check ✅ Passed The PR implementation addresses all coding requirements from #1289: automatic version registration (fern/versions/vX.Y.Z.yml generation, fern/docs.yml updates), hardened frozen checkout (glob guards, warnings instead of failures, MDX img tag fixes, yq-based stamping).
Out of Scope Changes check ✅ Passed All changes are within scope: MDX fixes in preview workflow and version registration/hardening logic in publish workflow directly support the stated objectives with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/publish-fern-docs.yml (1)

93-93: 💤 Low value

Minor inconsistency with preview workflow's tag verification.

This step uses bare ref resolution (git rev-parse "$version"), while the preview workflow at line 69 uses explicit tag verification (git rev-parse -q --verify "refs/tags/$version"). Both work in practice since version names like v1.5.0 are typically only tags, but the explicit form is more precise and guards against accidentally matching a branch with the same name.

Consider aligning with the preview workflow for consistency:

🔧 Suggested change
-           if git rev-parse "$version" >/dev/null 2>&1; then
+           if git rev-parse -q --verify "refs/tags/$version" >/dev/null 2>&1; then
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/publish-fern-docs.yml at line 93, The tag-existence check
currently uses a bare ref resolution (git rev-parse "$version"); update the
check to the explicit tag verification used in the preview workflow by using git
rev-parse -q --verify "refs/tags/$version" so it only matches tags (not
branches) when evaluating the variable version; replace the condition around the
git rev-parse call accordingly where the step performs the tag verification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/publish-fern-docs.yml:
- Line 93: The tag-existence check currently uses a bare ref resolution (git
rev-parse "$version"); update the check to the explicit tag verification used in
the preview workflow by using git rev-parse -q --verify "refs/tags/$version" so
it only matches tags (not branches) when evaluating the variable version;
replace the condition around the git rev-parse call accordingly where the step
performs the tag verification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a555ee22-c782-478c-ab4c-fd3a2ad5edd8

📥 Commits

Reviewing files that changed from the base of the PR and between a255042 and 2ffefad.

📒 Files selected for processing (2)
  • .github/workflows/fern-docs-preview-build.yml
  • .github/workflows/publish-fern-docs.yml

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/publish-fern-docs.yml (1)

73-85: 💤 Low value

Consider adding a pull/rebase before push for robustness.

The push on line 85 could fail if main moves between checkout and push (e.g., external commits). While the concurrency control helps prevent races within this workflow, external pushes to main could still cause failures.

This is acceptable for infrequent tag-push automation since failed runs can be retried, but adding a pull before push would improve resilience.

♻️ Optional: pull before push
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add fern/versions/ fern/docs.yml
          git commit -m "chore(fern): add ${TAG_VERSION} version entry [automated]"
+          git pull --rebase origin main
          git push origin main
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/publish-fern-docs.yml around lines 73 - 85, The
commit-and-push step that runs TAG_VERSION and executes git push origin main can
fail if origin/main changed after checkout; update the block that configures git
user and runs git add/commit (the step named "Commit new version entry") to
fetch and rebase the latest main before pushing (e.g., run git fetch origin &&
git rebase origin/main or git pull --rebase origin main), handle non-zero exit
(abort/exit with message) if rebase fails, and only run git push origin main
after a successful fast-forward/rebase to avoid push conflicts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/publish-fern-docs.yml:
- Around line 73-85: The commit-and-push step that runs TAG_VERSION and executes
git push origin main can fail if origin/main changed after checkout; update the
block that configures git user and runs git add/commit (the step named "Commit
new version entry") to fetch and rebase the latest main before pushing (e.g.,
run git fetch origin && git rebase origin/main or git pull --rebase origin
main), handle non-zero exit (abort/exit with message) if rebase fails, and only
run git push origin main after a successful fast-forward/rebase to avoid push
conflicts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 092d7c04-419c-4df9-8e61-e67c823fd224

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffefad and a89f5ba.

📒 Files selected for processing (1)
  • .github/workflows/publish-fern-docs.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Automate Fern version registration on docs tag push

2 participants