Skip to content

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

Merged
kvaps merged 1 commit intomainfrom
fix/openapi-skip-prereleases
May 7, 2026
Merged

fix(ci): skip prereleases when picking openapi.json release#515
kvaps merged 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
    • Improved release selection when fetching OpenAPI docs: the process now excludes prereleases and drafts to ensure a stable release tag is chosen as the latest.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 28, 2026

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 155c98c
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/69fc38863df31200083b54c5
😎 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

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c10ae1d-df51-48dc-b030-85a417716cc4

📥 Commits

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

📒 Files selected for processing (1)
  • hack/download_openapi.sh
🚧 Files skipped from review as they are similar to previous changes (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

Release Selection Logic

Layer / File(s) Summary
Release filtering and selection
hack/download_openapi.sh
Modified jq filtering to exclude both .draft == false and .prerelease == false before applying the tag regex, sort -V, and tail -1, 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 describes the main change: fixing the CI script to exclude prerelease versions when selecting the latest OpenAPI release.
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.

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>
@myasnikovdaniil myasnikovdaniil force-pushed the fix/openapi-skip-prereleases branch from 8cb2662 to 155c98c Compare May 7, 2026 07:00
@kvaps kvaps merged commit c0241ba into main May 7, 2026
6 checks passed
@kvaps kvaps deleted the fix/openapi-skip-prereleases branch May 7, 2026 16:47
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.

2 participants