Fix version validation for v0 in non-breaking policy. (#130)
This commit is contained in:
committed by
pullfrog[bot]
parent
cfd7f45db9
commit
ef9c1ae412
@@ -140233,7 +140233,7 @@ function validateCompatibility(payloadVersion, actionVersion) {
|
|||||||
const major = payloadSemVer.major;
|
const major = payloadSemVer.major;
|
||||||
const minor = payloadSemVer.minor;
|
const minor = payloadSemVer.minor;
|
||||||
const patch = payloadSemVer.patch;
|
const patch = payloadSemVer.patch;
|
||||||
const compatibilityRange = COMPATIBILITY_POLICY === "same-features" ? `^${major}.${minor}.${major === 0 ? patch : 0}` : `^${major}.${major === 0 ? minor : 0}.0`;
|
const compatibilityRange = COMPATIBILITY_POLICY === "same-features" ? `^${major}.${minor}.${major === 0 ? patch : 0}` : `^${major}.${major === 0 ? minor : 0}.${major === 0 ? "x" : 0}`;
|
||||||
if (!import_semver.default.satisfies(actionVersion, compatibilityRange)) {
|
if (!import_semver.default.satisfies(actionVersion, compatibilityRange)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Payload version ${payloadVersion} is incompatible with action version ${actionVersion}. Please update your workflow to use at least ${import_semver.default.minVersion(compatibilityRange)} version of the action.`
|
`Payload version ${payloadVersion} is incompatible with action version ${actionVersion}. Please update your workflow to use at least ${import_semver.default.minVersion(compatibilityRange)} version of the action.`
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ describe('validateCompatibility', () => {
|
|||||||
["1.0.0", "1.0.0"], // same
|
["1.0.0", "1.0.0"], // same
|
||||||
["1.0.0-alpha.1", "1.0.0"], // action is newer than pre-release
|
["1.0.0-alpha.1", "1.0.0"], // action is newer than pre-release
|
||||||
["0.1.0", "0.1.1"], // action is newer during active development
|
["0.1.0", "0.1.1"], // action is newer during active development
|
||||||
|
["0.0.158", "0.0.158"], // bug #129
|
||||||
|
["0.0.159", "0.0.158"], // bug #129
|
||||||
|
["0.0.158", "0.0.159"], // bug #129
|
||||||
["1.0.0", "1.0.1"], // action patched
|
["1.0.0", "1.0.1"], // action patched
|
||||||
["1.0.0", "1.1.0"], // action has a new feature (backward compatible)
|
["1.0.0", "1.1.0"], // action has a new feature (backward compatible)
|
||||||
["1.0.1", "1.0.0"], // payload is newer (patch)
|
["1.0.1", "1.0.0"], // payload is newer (patch)
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ export function validateCompatibility(payloadVersion: string, actionVersion: str
|
|||||||
|
|
||||||
const compatibilityRange = COMPATIBILITY_POLICY === 'same-features'
|
const compatibilityRange = COMPATIBILITY_POLICY === 'same-features'
|
||||||
? `^${major}.${minor}.${major === 0 ? patch : 0}`
|
? `^${major}.${minor}.${major === 0 ? patch : 0}`
|
||||||
: `^${major}.${major === 0 ? minor : 0}.0`; // non-breaking
|
: `^${major}.${major === 0 ? minor : 0}.${major === 0 ? "x" : 0}`; // non-breaking
|
||||||
|
|
||||||
if (!semver.satisfies(actionVersion, compatibilityRange)) {
|
if (!semver.satisfies(actionVersion, compatibilityRange)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user