scripts/prepare-release: fix base version handling in non-prereleases

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-01 14:59:03 +01:00
parent d3c107da13
commit 82f855f9a0
+14 -6
View File
@@ -62,14 +62,22 @@ async function updatePatchVersions() {
throw new Error(`Invalid base version ${version} for package ${name}`);
}
const currentVersion = semver.parse(pkg.packageJson.version);
const targetVersion = semver.parse(version).inc('patch');
targetVersion.prerelease = currentVersion.prerelease;
let targetVersion = version;
// If we're currently in a pre-release we need to manually execute the
// patch bump up to the next version. And we also need to make sure we
// resume the releases at the same pre-release tag.
const currentPrerelease = semver.prerelease(pkg.packageJson.version);
if (currentPrerelease) {
const parsed = targetVersion.parse(version);
parsed.inc('patch');
parsed.prerelease = currentPrerelease;
targetVersion = parsed.format();
}
const targetVersionString = targetVersion.format();
pendingVersionBumps.set(name, {
targetVersion: targetVersionString,
targetRange: `^${targetVersionString}`,
targetVersion,
targetRange: `^${targetVersion}`,
});
}