Skip to content

Commit

Permalink
Merge branch 'main' into feat/composition-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Nov 6, 2024
2 parents ca7bbd8 + e4df668 commit cd20b75
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/ci/codegen/createGitHubReleases.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fsp from 'fs/promises';
import { ensureGitHubToken, getOctokit, OWNER, run, setVerbose, toAbsolutePath } from '../../common.js';
import { isPreRelease } from '../../release/versionsHistory.js';
import type { Language } from '../../types.js';
import { cloneRepository } from '../utils.js';

import { resolve } from 'path';
import { commitStartRelease } from './text.js';

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

// extract the changelog from CHANGELOG.md, until the first ## to the second ##
const fullChangelog = (await fsp.readFile(resolve(tempGitDir, 'CHANGELOG.md')))
.toString()
.matchAll(/^##.*?\n(.*?)##/gms);
if (!fullChangelog) {
throw new Error('unable to find changelog');
}

const changelog = [...fullChangelog][0][1].trim().replaceAll(/- \[/g, '* [');

const repository = `algoliasearch-client-${lang}`;
const repositoryLink = `https://github.com/${OWNER}/${repository}`;
const content = `
New ${isMajor ? '**major** ' : ''}version released!
# New ${isMajor ? '**major** ' : ''}version released!
## What's Changed
${changelog}
**Full Changelog**: ${repositoryLink}/compare/${previousVersion}...${newVersion}
→ [Browse the Algolia documentation](https://www.algolia.com/doc/libraries/${lang})
→ [Browse the changelog](${repositoryLink}/blob/main/CHANGELOG.md)
→ [Browse the commits](${repositoryLink}/compare/${previousVersion}...${newVersion})`;
`;

try {
await getOctokit().repos.createRelease({
Expand Down

0 comments on commit cd20b75

Please sign in to comment.