Skip to content

fix(ci): skip prereleases when picking openapi.json release#515

Open
myasnikovdaniil wants to merge 1 commit intomainfrom
fix/openapi-skip-prereleases
Open

fix(ci): skip prereleases when picking openapi.json release#515
myasnikovdaniil wants to merge 1 commit intomainfrom
fix/openapi-skip-prereleases

Conversation

@myasnikovdaniil
Copy link
Copy Markdown
Contributor

@myasnikovdaniil myasnikovdaniil commented Apr 28, 2026

Summary

hack/download_openapi.sh was downloading openapi.json from v1.3.0-rc.1 for the v1.3 docs, even though stable v1.3.0 exists. Production currently shows api/apps/v1alpha1/v1.3.0-rc.1-1-g12bf6b0e at /docs/v1.3/cozystack-api/api.json.

Root cause

Two compounding issues:

  1. sort -V orders prerelease tags AFTER the stable release, opposite of semver:
    $ printf 'v1.3.0\nv1.3.0-rc.1\nv1.3.0-rc.2\n' | sort -V
    v1.3.0
    v1.3.0-rc.1
    v1.3.0-rc.2
    
  2. The jq filter only excluded drafts (select(.draft == false)), not prereleases — so v1.3.0-rc.1 (marked prerelease: true on GitHub) survived to the sort.

Combined, tail -1 picked the rc instead of the stable release.

Fix

Add and .prerelease == false to the jq filter. Prereleases are dropped before sorting, so sort -V's quirk no longer matters.

Verified locally against the live releases API:

version before after
v1.1 v1.1.6 v1.1.6
v1.2 v1.2.3 v1.2.3
v1.3 v1.3.0-rc.1 v1.3.0

v1.1 and v1.2 were unaffected only because no rc tag is currently newer than the matching stable for those minors — the bug was latent there.

Test plan

  • CI build (./hack/download_openapi.sh && hugo --gc --minify) succeeds
  • After merge + Pages rebuild, https://cozystack.io/docs/v1.3/cozystack-api/api.json reports a version field derived from v1.3.0 (no -rc.1)

Summary by CodeRabbit

  • Chores
    • Updated release selection logic to ensure stable releases are prioritized over prerelease candidates when fetching OpenAPI documentation.

The build script picked v1.3.0-rc.1 over v1.3.0 for the v1.3 docs because
GNU `sort -V` orders prerelease tags AFTER the matching stable version
(opposite of semver), and the jq filter only excluded drafts. Add
`prerelease == false` to the filter so prerelease tags are dropped before
sorting.

Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 28, 2026

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 8cb2662
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/69f0a1b01242790008d5a2fa
😎 Deploy Preview https://deploy-preview-515--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c493caf-8d39-4020-b2b9-ae18163cd456

📥 Commits

Reviewing files that changed from the base of the PR and between bc2745e and 8cb2662.

📒 Files selected for processing (1)
  • hack/download_openapi.sh

📝 Walkthrough

Walkthrough

The hack/download_openapi.sh script's GitHub release selection logic now filters out both draft and prerelease releases when determining the latest tag for each docs version, preventing prerelease versions from being selected as stable releases.

Changes

Cohort / File(s) Summary
Release Selection Logic
hack/download_openapi.sh
Modified jq filtering to exclude draft and prerelease releases when determining latest_tag, ensuring only stable releases are selected.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A filter most precise, now shining bright,
No drafts or release candidates in sight!
Stable versions only, the true path we take,
Each tag now perfect, no mistakes to make!

🚥 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 summarizes the main change: updating the OpenAPI release selection logic to exclude prerelease versions when choosing stable releases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openapi-skip-prereleases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the hack/download_openapi.sh script to ensure that only stable releases are selected by explicitly excluding prereleases in the jq filter. This modification prevents GNU sort -V from incorrectly identifying a release candidate as the latest version over a stable release. I have no feedback to provide.

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.

1 participant