ethers-rs/.github/scripts/release-tag-from.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.2 KiB
JavaScript
Raw Normal View History

const semver = require("semver");
const previousVersion = (currentVersion, releaseType) => {
const parsedVersion = semver.parse(currentVersion);
switch (releaseType) {
case "major": {
return `v${parsedVersion.major - 1}.0.0`;
2022-09-28 18:58:26 +00:00
}
case "minor": {
return `v${parsedVersion.major}.${parsedVersion.minor - 1}.0`;
2022-09-28 18:58:26 +00:00
}
case "patch": {
return `v${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch - 1}`;
2022-09-28 18:58:26 +00:00
}
case "alpha": {
return `v${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}-alpha.${
parsedVersion.prerelease[1] - 1
2022-09-28 18:58:26 +00:00
}`;
}
case "beta": {
return `v${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}-beta.${
parsedVersion.prerelease[1] - 1
2022-09-28 18:58:26 +00:00
}`;
}
case "rc": {
return `v${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}-rc.${
parsedVersion.prerelease[1] - 1
2022-09-28 18:58:26 +00:00
}`;
}
}
};
const [currentVersion, releaseType] = process.argv.slice(-2);
console.log(previousVersion(currentVersion, releaseType));