From 7c2bf7263df554e3ebc2ee8ac2d18c8053a80ab4 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 18 Nov 2020 21:47:45 +0100 Subject: [PATCH] Ensure an engine-only ruby-version picks the latest stable version and not a preview or RC --- common.js | 4 ++++ dist/index.js | 7 ++++++- index.js | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common.js b/common.js index 4587abc..f11ba12 100644 --- a/common.js +++ b/common.js @@ -28,6 +28,10 @@ export function isHeadVersion(rubyVersion) { return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin' } +export function isStableVersion(rubyVersion) { + return /^\d+(\.\d+)*$/.test(rubyVersion) +} + export async function hashFile(file) { // See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts const hash = crypto.createHash('sha256') diff --git a/dist/index.js b/dist/index.js index 23dc791..44a4c39 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32096,6 +32096,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drive", function() { return drive; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isStableVersion", function() { return isStableVersion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldExtractInToolCache", function() { return shouldExtractInToolCache; }); @@ -32132,6 +32133,10 @@ function isHeadVersion(rubyVersion) { return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin' } +function isStableVersion(rubyVersion) { + return /^\d+(\.\d+)*$/.test(rubyVersion) +} + async function hashFile(file) { // See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts const hash = crypto.createHash('sha256') @@ -51290,7 +51295,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() - const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion)) + const found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion)) if (found) { version = found } else { diff --git a/index.js b/index.js index 3e8c940..0b9bbf9 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() - const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion)) + const found = latestToFirstVersion.find(v => common.isStableVersion(v) && v.startsWith(parsedVersion)) if (found) { version = found } else {