Skip to content

Commit 7c2bf72

Browse files
committed
Ensure an engine-only ruby-version picks the latest stable version and not a preview or RC
1 parent 34fbbc1 commit 7c2bf72

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export function isHeadVersion(rubyVersion) {
2828
return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
2929
}
3030

31+
export function isStableVersion(rubyVersion) {
32+
return /^\d+(\.\d+)*$/.test(rubyVersion)
33+
}
34+
3135
export async function hashFile(file) {
3236
// See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts
3337
const hash = crypto.createHash('sha256')

dist/index.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
132132
let version = parsedVersion
133133
if (!engineVersions.includes(parsedVersion)) {
134134
const latestToFirstVersion = engineVersions.slice().reverse()
135-
const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
135+
const found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion))
136136
if (found) {
137137
version = found
138138
} else {

0 commit comments

Comments
 (0)