Skip to content

Add support for rc and beta versions in go.mod file - #701

Merged
v-HarithaVattikuti merged 3 commits into
actions:mainfrom
arnested:rc
Nov 3, 2026
Merged

v-HarithaVattikuti merged 3 commits into
actions:mainfrom
arnested:rc

Conversation

@arnested

@arnested arnested commented Dec 17, 2025 •

Copy link
Copy Markdown
Contributor

Description:
The regex in parseGoVersionFile() didn't consider rc and beta versions. The regex has been extended.

In findMatch() the match is checked using semver.satisfies(). But semver.satisfies() doesn't no about Go's non-semver rc and beta version formats (1.16c1 instead of 1.16.0-rc.1).

We cannot use makeSemver() on versionSpec and compare the result using semver.satisfies() because versionSpec could be, well, a spec. Instead we first check if there is a strict match between the candidate version and the versionSpec.

Related issue:

Fixes #525.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI review requested due to automatic review settings December 17, 2025 23:03
@arnested
arnested requested a review from a team as a code owner December 17, 2025 23:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for matching Go versions in rc and beta formats (e.g., 1.14rc1, 1.18beta1) when specified as version inputs. It extends both the regex pattern for parsing go.mod/go.work files and the version matching logic in findMatch().

Key changes:

  • Enhanced the regex in parseGoVersionFile() to recognize beta/rc suffixes in version strings
  • Modified findMatch() to perform a strict equality check using makeSemver() before falling back to semver.satisfies(), enabling direct matching of Go-format version specs like 1.14rc1
  • Added a test case to verify that findMatch() correctly resolves Go-format rc version specs

Reviewed changes

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

File Description
src/installer.ts Extended regex pattern to match beta/rc versions in go directive; added strict equality check in findMatch() for Go-format version specs
dist/setup/index.js Compiled distribution file reflecting the source changes
tests/setup-go.test.ts Added test case for finding pre-release versions using Go version format (1.14rc1)

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

Comment thread __tests__/setup-go.test.ts Resolved
Comment thread src/installer.ts Resolved
Comment thread src/installer.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread __tests__/setup-go.test.ts Resolved
Comment thread src/installer.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.


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

Comment thread src/installer.ts Resolved
@arnested

Copy link
Copy Markdown
Contributor Author

I have rebased the branch on top of the v7.0.0 release.

@arnested

arnested commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebased against main.

@v-jitenderpalsingh

Copy link
Copy Markdown
Contributor

Hello @arnested,

Thank you for your contribution and for adding support for RC and beta versions in the go.mod file. Could you please address the following points?

  • Extend the toolchain directive regex to support beta versions, consistent with the updated go directive.
  • Ensure tool-cache lookup handles Go-native prerelease versions correctly, so already cached versions are reused instead of being downloaded again.

Would you also be willing to extend this PR to accept Go-native versions with the go prefix in the go-version input, such as go1.27, go1.18beta2, and go1.27rc2, as discussed in #63 while preserving existing inputs and version ranges? Please let us know if you would be interested in implementing this additional support.

Thank you again for your work on this!

@arnested

Copy link
Copy Markdown
Contributor Author

I'll have a look at it. It'll probably be in a week or so. I'm literally on the way to the airport for a vacation 🧳

@arnested

arnested commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

I managed to squeeze in a bit of time and have pushed changes for the toolchain directive and tool-cache lookup. I've had no look at #63 yet.

@v-jitenderpalsingh

Copy link
Copy Markdown
Contributor

Hello @arnested ,
Thank you for the updates! Just following up to ask whether you’ve had a chance to look at #63 and consider extending this PR to accept Go-native versions with the go prefix in the go-version input. Please let us know when you have time.

@arnested

Copy link
Copy Markdown
Contributor Author

Hi @v-jitenderpalsingh

I had a first take at it. Think it worked, but although not complicated, it didn't find it very readable/easy to understand. Haven't gotten around to a second attempt, yet.

@v-jitenderpalsingh

Copy link
Copy Markdown
Contributor

Hello @arnested,

Thank you for looking into this! We’re now handling go prefixed versions in the go-version input separately in PR #804, so we’ll keep this PR focused on RC and beta version support through the go-version-file input. We appreciate your time and contributions!

@arnested

arnested commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main.

@v-jitenderpalsingh

Copy link
Copy Markdown
Contributor

Hi @arnested, thank you for rebasing! It looks like the branch is still missing some recent changes from main. Could you please fetch the latest upstream changes and rebase against the updated main branch? Thank you!

The regex in `parseGoVersionFile()` didn't consider rc and beta
versions. The regex has been extended.

In `findMatch()` the match is checked using `semver.satisfies()`. But
`semver.satisfies()` doesn't no about Go's non-semver rc and beta
version formats (1.16c1 instead of 1.16.0-rc.1).

We cannot use `makeSemver()` on `versionSpec` and compare the result
using `semver.satisfies()` because `versionSpec` could be, well, a
spec. Instead we first check if there is a strict match between the
candidate version and the versionSpec.

Fixes actions#525.
@arnested

arnested commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @arnested, thank you for rebasing! It looks like the branch is still missing some recent changes from main. Could you please fetch the latest upstream changes and rebase against the updated main branch? Thank you!

Doh! It went a bit to fast this morning. I rebased against main on my fork 😄 I push a better rebase now 😄

@v-HarithaVattikuti
v-HarithaVattikuti merged commit 7d2730e into actions:main Nov 3, 2026
126 of 130 checks passed
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.

The RC version in the go.mod file cannot be retrieved

5 participants