Merge branch 'ci-fix' into 'master'
ci: Fix version comparison bug See merge request riftenlabs/lib/wizardconnect!22
This commit is contained in:
commit
5b99a9e9c3
2 changed files with 22 additions and 4 deletions
|
|
@ -94,6 +94,14 @@ function getCurrentVersion(packagePath) {
|
|||
return packageJson.version;
|
||||
}
|
||||
|
||||
function compareVersions(a, b) {
|
||||
const [aMajor, aMinor, aPatch] = a.split('.').map(Number);
|
||||
const [bMajor, bMinor, bPatch] = b.split('.').map(Number);
|
||||
if (aMajor !== bMajor) return aMajor - bMajor;
|
||||
if (aMinor !== bMinor) return aMinor - bMinor;
|
||||
return aPatch - bPatch;
|
||||
}
|
||||
|
||||
function bumpVersion(currentVersion, latestNpmVersion) {
|
||||
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
||||
|
||||
|
|
@ -102,12 +110,13 @@ function bumpVersion(currentVersion, latestNpmVersion) {
|
|||
}
|
||||
|
||||
const [npmMajor, npmMinor, npmPatch] = latestNpmVersion.split('.').map(Number);
|
||||
const cmp = compareVersions(currentVersion, latestNpmVersion);
|
||||
|
||||
if (currentVersion > latestNpmVersion) {
|
||||
if (cmp > 0) {
|
||||
return `${major}.${minor}.${patch + 1}`;
|
||||
}
|
||||
|
||||
if (latestNpmVersion > currentVersion) {
|
||||
if (cmp < 0) {
|
||||
return `${npmMajor}.${npmMinor}.${npmPatch + 1}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,14 @@ function getCurrentVersion(packagePath) {
|
|||
return packageJson.version;
|
||||
}
|
||||
|
||||
function compareVersions(a, b) {
|
||||
const [aMajor, aMinor, aPatch] = a.split('.').map(Number);
|
||||
const [bMajor, bMinor, bPatch] = b.split('.').map(Number);
|
||||
if (aMajor !== bMajor) return aMajor - bMajor;
|
||||
if (aMinor !== bMinor) return aMinor - bMinor;
|
||||
return aPatch - bPatch;
|
||||
}
|
||||
|
||||
function bumpVersion(currentVersion, latestNpmVersion) {
|
||||
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
||||
|
||||
|
|
@ -86,12 +94,13 @@ function bumpVersion(currentVersion, latestNpmVersion) {
|
|||
}
|
||||
|
||||
const [npmMajor, npmMinor, npmPatch] = latestNpmVersion.split('.').map(Number);
|
||||
const cmp = compareVersions(currentVersion, latestNpmVersion);
|
||||
|
||||
if (currentVersion > latestNpmVersion) {
|
||||
if (cmp > 0) {
|
||||
return `${major}.${minor}.${patch + 1}`;
|
||||
}
|
||||
|
||||
if (latestNpmVersion > currentVersion) {
|
||||
if (cmp < 0) {
|
||||
return `${npmMajor}.${npmMinor}.${npmPatch + 1}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue