From f558f9692c94449502db14bb6753df59610c26a7 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Sat, 30 Jan 2021 21:34:05 +0100 Subject: [PATCH] fix: ensure that versions are valid SerVer before comparing --- app/main.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/main.js b/app/main.js index 96ed4fd..496a231 100644 --- a/app/main.js +++ b/app/main.js @@ -51,7 +51,18 @@ async function run () { } const minVersion = core.getInput('minVersion', { required: false }) - if (semver.lt(version, minVersion)) { + + // Ensure that version and minVersion are valid SemVer strings + const minVersionSemVer = semver.coerce(minVersion) + const versionSemVer = semver.coerce(version) + if (!minVersionSemVer) { + core.warning(`Skipping min version check. ${minVersion} is not valid SemVer`) + } + if(!versionSemVer) { + core.warning(`Skipping min version check. ${version} is not valid SemVer`) + } + + if (minVersionSemVer && versionSemVer && semver.lt(versionSemVer, minVersion)) { core.warning(`Version "${version}" is lower than minimum "${minVersion}"`) return }