Skip to content

Commit 53262f3

Browse files
bump-version: handle case when main version major gets bumped
1 parent 390f4ef commit 53262f3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/bump-version.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ let release = JSON.parse(packageJson).version;
1212

1313
let newVersion = latestPublish;
1414

15+
// If the main release gets a major bump but did not get published yet, the package.json version
16+
// will be higher than the one retrieved from the marketplace, so we need to increment from the main release
17+
// E.g. package.json gets bumped to 1.5.0 -> 1.6.0
18+
if (semver.major(release) - semver.major(latestPublish) === 1) {
19+
newVersion = semver.inc(release, "minor", semver.rel);
20+
}
1521
// A prepublished version must be one minor higher than a regular published version.
1622
// E.g. if package.json has version 1.3.0 and there is no prepublished version yet,
1723
// increment minor by one -> 1.4.0.
18-
if (semver.minor(latestPublish) === semver.minor(release)) {
24+
else if (semver.minor(latestPublish) === semver.minor(release)) {
1925
newVersion = semver.inc(newVersion, "minor", semver.rel);
2026
}
2127
// Increment the version patch. E.g. if we fetch version 1.4.0 as the latest pre-release,

0 commit comments

Comments
 (0)