Skip to content

Commit cd20b75

Browse files
authored
Merge branch 'main' into feat/composition-alpha
2 parents ca7bbd8 + e4df668 commit cd20b75

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

scripts/ci/codegen/createGitHubReleases.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import fsp from 'fs/promises';
12
import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.js';
23
import { isPreRelease } from '../../release/versionsHistory.js';
34
import type { Language } from '../../types.js';
45
import { cloneRepository } from '../utils.js';
56

7+
import { resolve } from 'path';
68
import { commitStartRelease } from './text.js';
79

810
async function createGitHubRelease(lang: Language): Promise<void> {
@@ -38,14 +40,27 @@ async function createGitHubRelease(lang: Language): Promise<void> {
3840
previousVersion = tags[tags.length - 1];
3941
}
4042

43+
// extract the changelog from CHANGELOG.md, until the first ## to the second ##
44+
const fullChangelog = (await fsp.readFile(resolve(tempGitDir, 'CHANGELOG.md')))
45+
.toString()
46+
.matchAll(/^##.*?\n(.*?)##/gms);
47+
if (!fullChangelog) {
48+
throw new Error('unable to find changelog');
49+
}
50+
51+
const changelog = [...fullChangelog][0][1].trim().replaceAll(/- \[/g, '* [');
52+
4153
const repository = `algoliasearch-client-${lang}`;
4254
const repositoryLink = `https://github.com/${OWNER}/${repository}`;
4355
const content = `
44-
New ${isMajor ? '**major** ' : ''}version released!
56+
# New ${isMajor ? '**major** ' : ''}version released!
57+
## What's Changed
58+
${changelog}
59+
60+
**Full Changelog**: ${repositoryLink}/compare/${previousVersion}...${newVersion}
4561
4662
→ [Browse the Algolia documentation](https://www.algolia.com/doc/libraries/${lang})
47-
→ [Browse the changelog](${repositoryLink}/blob/main/CHANGELOG.md)
48-
→ [Browse the commits](${repositoryLink}/compare/${previousVersion}...${newVersion})`;
63+
`;
4964

5065
try {
5166
await getOctokit().repos.createRelease({

0 commit comments

Comments
 (0)