|
| 1 | +import fsp from 'fs/promises'; |
1 | 2 | import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.js';
|
2 | 3 | import { isPreRelease } from '../../release/versionsHistory.js';
|
3 | 4 | import type { Language } from '../../types.js';
|
4 | 5 | import { cloneRepository } from '../utils.js';
|
5 | 6 |
|
| 7 | +import { resolve } from 'path'; |
6 | 8 | import { commitStartRelease } from './text.js';
|
7 | 9 |
|
8 | 10 | async function createGitHubRelease(lang: Language): Promise<void> {
|
@@ -38,14 +40,27 @@ async function createGitHubRelease(lang: Language): Promise<void> {
|
38 | 40 | previousVersion = tags[tags.length - 1];
|
39 | 41 | }
|
40 | 42 |
|
| 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 | + |
41 | 53 | const repository = `algoliasearch-client-${lang}`;
|
42 | 54 | const repositoryLink = `https://github.com/${OWNER}/${repository}`;
|
43 | 55 | 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} |
45 | 61 |
|
46 | 62 | → [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 | +`; |
49 | 64 |
|
50 | 65 | try {
|
51 | 66 | await getOctokit().repos.createRelease({
|
|
0 commit comments