Skip to content

fix: filter prereleases by semver tag instead of GitHub API field#498

Merged
johnstcn merged 1 commit intofix/go-version-checkfrom
fix/semver-prerelease-handling
Mar 25, 2026
Merged

fix: filter prereleases by semver tag instead of GitHub API field#498
johnstcn merged 1 commit intofix/go-version-checkfrom
fix/semver-prerelease-handling

Conversation

@johnstcn
Copy link
Member

@johnstcn johnstcn commented Mar 25, 2026

  • Extract highestRelease() helper: filters prereleases via semver.Version.Prerelease() instead of GitHub API prerelease boolean
  • Extract formatVersion() helper for the repeated Sprintf pattern
  • Fix pre-existing bug: missing continue after semver.NewVersion() errors caused stale version reuse
  • Fix copy-paste bug: old-stable debug line logged wrong variable
  • Add table-driven tests for both helpers (9 + 2 cases)

Alternative approach to #497 — operates on the version string (source of truth) rather than relying on GitHub metadata.

🤖 This PR was created with the help of Coder Agents, and has been reviewed by my human. 🧑‍💻

@johnstcn johnstcn self-assigned this Mar 25, 2026
@github-actions
Copy link

github-actions bot commented Mar 25, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@johnstcn johnstcn changed the base branch from main to fix/go-version-check March 25, 2026 10:25
…nky promise

Replace the GitHub API prerelease boolean check with semver.Version.Prerelease()
filtering — because the version string is the source of truth, not metadata.

Also:
- Extract highestRelease() to eliminate 3x copy-pasted loops
- Extract formatVersion() for the repeated Sprintf pattern
- Fix pre-existing bug: missing continue after semver parse errors
  caused stale version from prior iteration to be used
- Add table-driven tests for both helpers (there were none before)
@johnstcn johnstcn force-pushed the fix/semver-prerelease-handling branch from 2c69b59 to 924d5cc Compare March 25, 2026 10:31
@johnstcn johnstcn marked this pull request as ready for review March 25, 2026 10:32
Copilot AI review requested due to automatic review settings March 25, 2026 10:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the scripts/coderversion helper script to select the highest stable release based on SemVer parsing (prerelease suffix detection) rather than relying on GitHub API prerelease metadata, preventing integration tests from selecting non-existent image tags.

Changes:

  • Extract highestRelease() to select the highest non-prerelease SemVer (optionally filtered by minor).
  • Extract formatVersion() to consistently format vMAJOR.MINOR.PATCH (dropping prerelease/build metadata).
  • Add table-driven tests covering prerelease filtering, minor filtering, and invalid/empty inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scripts/coderversion/main.go Refactors version selection into helpers and filters prereleases via SemVer prerelease parsing.
scripts/coderversion/main_test.go Adds unit tests for highestRelease() and formatVersion().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for adding tests too. 👍

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

👌 LGTM

@johnstcn johnstcn merged commit 7dff142 into fix/go-version-check Mar 25, 2026
11 checks passed
@johnstcn johnstcn deleted the fix/semver-prerelease-handling branch March 25, 2026 10:42
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants