Skip to content

Commit 16c666a

Browse files
authored
Merge branch 'main' into feat/helper-tests
2 parents fcc621e + c10e048 commit 16c666a

File tree

7 files changed

+2109
-63
lines changed

7 files changed

+2109
-63
lines changed

config/release.config.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,73 @@
2121
"gitAuthor": {
2222
"name": "algolia-bot",
2323
"email": "[email protected]"
24+
},
25+
"lts": {
26+
"csharp": {
27+
"6.1.17": {
28+
"start": "2024-01-01",
29+
"end": "2024-08-01"
30+
}
31+
},
32+
"dart": {
33+
"1.11.1": {
34+
"start": "2024-06-12",
35+
"end": "2024-12-12"
36+
}
37+
},
38+
"go": {
39+
"3.31.1": {
40+
"start": "2024-01-01",
41+
"end": "2024-08-01"
42+
}
43+
},
44+
"java": {
45+
"3.16.9": {
46+
"start": "2024-01-01",
47+
"end": "2024-08-01"
48+
}
49+
},
50+
"javascript": {
51+
"4.23.3": {
52+
"start": "2024-01-01",
53+
"end": "2024-08-01"
54+
}
55+
},
56+
"kotlin": {
57+
"2.1.12": {
58+
"start": "2024-01-01",
59+
"end": "2024-08-01"
60+
}
61+
},
62+
"php": {
63+
"3.4.1": {
64+
"start": "2024-01-01",
65+
"end": "2024-08-01"
66+
}
67+
},
68+
"python": {
69+
"3.0.0": {
70+
"start": "2024-01-01",
71+
"end": "2024-08-01"
72+
}
73+
},
74+
"ruby": {
75+
"2.3.4": {
76+
"start": "2024-01-01",
77+
"end": "2024-08-01"
78+
}
79+
},
80+
"scala": {
81+
"1.45.2": {
82+
"start": "2024-01-01",
83+
"end": "2024-08-01"
84+
}
85+
},
86+
"swift": {
87+
"8.20.1": {
88+
"start": "2024-01-01",
89+
"end": "2024-08-01"
90+
}
91+
}
2492
}
2593
}

scripts/ci/actions/restore-artifacts/builddir/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/ci/actions/restore-artifacts/builddir/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { getGitAuthor } from './release/common.js';
1717
import { createSpinner } from './spinners.js';
1818
import type { Generator, GeneratorMode, Language, RunOptions } from './types.js';
1919

20+
export const fullReleaseConfig = releaseConfig;
21+
2022
export const MAIN_BRANCH = releaseConfig.mainBranch;
2123
export const OWNER = releaseConfig.owner;
2224
export const REPO = releaseConfig.repo;

scripts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"fs-extra": "11.2.0",
4848
"js-yaml": "4.1.0",
4949
"knip": "5.18.2",
50+
"lts": "1.2.0",
5051
"micromatch": "4.0.7",
5152
"semver": "7.6.2",
5253
"spinnies": "0.5.1",

scripts/release/createReleasePR.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable no-console */
2+
import fsp from 'fs/promises';
3+
24
import chalk from 'chalk';
35
import dotenv from 'dotenv';
6+
import lts from 'lts';
47
import semver from 'semver';
58

69
import generationCommitText from '../ci/codegen/text.js';
@@ -19,6 +22,8 @@ import {
1922
gitBranchExists,
2023
setVerbose,
2124
configureGitHubAuthor,
25+
fullReleaseConfig,
26+
toAbsolutePath,
2227
} from '../common.js';
2328
import { getLanguageFolder, getPackageVersionDefault } from '../config.js';
2429
import type { Language } from '../types.js';
@@ -388,6 +393,78 @@ async function prepareGitEnvironment(): Promise<void> {
388393
await run('git pull origin $(git branch --show-current)');
389394
}
390395

396+
// updates the release.config.json file for the lts field, which contains a release history of start and end date support
397+
// inspired by node: https://github.com/nodejs/Release/blob/main/schedule.json, following https://github.com/nodejs/release#release-schedule, leveraging https://github.com/nodejs/lts-schedule
398+
async function updateLTS(versions: Versions, withGraphs?: boolean): Promise<void> {
399+
const start = new Date();
400+
const end = new Date(new Date().setMonth(new Date().getMonth() + 12));
401+
402+
let queryStart = start;
403+
let queryEnd = end;
404+
405+
for (const [lang, supportedVersions] of Object.entries(fullReleaseConfig.lts)) {
406+
const next = versions[lang].next;
407+
const current = versions[lang].current;
408+
409+
// no ongoing release for this client, nothing changes
410+
if (!next || next === current) {
411+
continue;
412+
}
413+
414+
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;
418+
}
419+
420+
supportedVersions[current].maintenance = end.toISOString().split('T')[0];
421+
}
422+
423+
supportedVersions[next] = {
424+
start: start.toISOString().split('T')[0],
425+
active: start.toISOString().split('T')[0],
426+
end: end.toISOString().split('T')[0],
427+
};
428+
429+
for (const [supportedVersion, dates] of Object.entries(supportedVersions)) {
430+
// The support has expired, we can drop it
431+
if ('maintenance' in dates && new Date(dates.maintenance as string) < start) {
432+
delete supportedVersions[supportedVersion];
433+
434+
continue;
435+
}
436+
437+
// Used to define the start of the rendered graph timeline
438+
const versionStart = new Date(dates.start);
439+
if (versionStart < queryStart) {
440+
queryStart = versionStart;
441+
}
442+
443+
// Used to define the end of the rendered graph timeline
444+
const versionEnd = new Date(dates.end);
445+
if (versionEnd > queryEnd) {
446+
queryEnd = versionEnd;
447+
}
448+
}
449+
450+
if (withGraphs) {
451+
lts.create({
452+
queryStart,
453+
queryEnd,
454+
png: toAbsolutePath(`config/${lang}-lts.png`),
455+
data: supportedVersions,
456+
projectName: '',
457+
excludeMaster: true,
458+
});
459+
}
460+
}
461+
462+
await fsp.writeFile(
463+
toAbsolutePath('config/release.config.json'),
464+
JSON.stringify(fullReleaseConfig, null, 2),
465+
);
466+
}
467+
391468
async function createReleasePR(): Promise<void> {
392469
await prepareGitEnvironment();
393470

@@ -398,6 +475,8 @@ async function createReleasePR(): Promise<void> {
398475
versions: readVersions(),
399476
commits: validCommits,
400477
});
478+
479+
await updateLTS(versions, true);
401480
const versionChanges = getVersionChangesText(versions);
402481

403482
console.log('Creating changelogs for all languages...');

0 commit comments

Comments
 (0)