Skip to content

Commit 2d46c5f

Browse files
authored
fix(scripts): properly handle maintenance versions (#3172)
1 parent b1d84b5 commit 2d46c5f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

scripts/release/createReleasePR.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,17 +407,27 @@ async function updateLTS(versions: Versions, withGraphs?: boolean): Promise<void
407407
const current = versions[lang].current;
408408

409409
// no ongoing release for this client, nothing changes
410-
if (!next || next === current) {
410+
if (!next || current === next) {
411411
continue;
412412
}
413413

414414
if (current in supportedVersions) {
415-
if (versions[lang].releaseType !== 'major') {
416-
// In the same major, the current version enters in maintenance mode, and the next become the new active
417-
delete supportedVersions[current].active;
415+
// when we release a new patch, the current version isn't maintained anymore, as we only provide SLA for the latest minor/previous major
416+
const nextMinor = next.match(/.+\.(.+)\..*/);
417+
const currentMinor = current.match(/.+\.(.+)\..*/);
418+
419+
if (!currentMinor || !nextMinor) {
420+
throw new Error(`unable to determine minor versions: ${currentMinor}, ${nextMinor}`);
418421
}
419422

420-
supportedVersions[current].maintenance = end.toISOString().split('T')[0];
423+
if (versions[lang].releaseType !== 'major' && currentMinor[1] === nextMinor[1]) {
424+
delete supportedVersions[current];
425+
} else {
426+
delete supportedVersions[current].active;
427+
428+
// any other release cases make the previous version enter in maintenance
429+
supportedVersions[current].maintenance = start.toISOString().split('T')[0];
430+
}
421431
}
422432

423433
supportedVersions[next] = {
@@ -428,7 +438,7 @@ async function updateLTS(versions: Versions, withGraphs?: boolean): Promise<void
428438

429439
for (const [supportedVersion, dates] of Object.entries(supportedVersions)) {
430440
// The support has expired, we can drop it
431-
if ('maintenance' in dates && new Date(dates.maintenance as string) < start) {
441+
if ('maintenance' in dates && new Date(dates.end as string) < start) {
432442
delete supportedVersions[supportedVersion];
433443

434444
continue;
@@ -476,7 +486,6 @@ async function createReleasePR(): Promise<void> {
476486
commits: validCommits,
477487
});
478488

479-
await updateLTS(versions, true);
480489
const versionChanges = getVersionChangesText(versions);
481490

482491
console.log('Creating changelogs for all languages...');
@@ -514,6 +523,8 @@ async function createReleasePR(): Promise<void> {
514523
console.log('Updating config files...');
515524
await updateAPIVersions(versions, changelog);
516525

526+
await updateLTS(versions, true);
527+
517528
const headBranch = `chore/prepare-release-${TODAY}`;
518529
console.log(`Switching to branch: ${headBranch}`);
519530
if (await gitBranchExists(headBranch)) {

0 commit comments

Comments
 (0)