fix: ensure that versions are valid SerVer before comparing

This commit is contained in:
Tomasz Pluskiewicz 2021-01-30 21:34:05 +01:00 committed by GitHub
parent 2451ded74e
commit f558f9692c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}