ci: Update release process to support major releases (no-changelog) (#6552)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-06-27 16:15:29 +02:00
committed by GitHub
parent f89ef83c76
commit 5b5f30fd33
4 changed files with 26 additions and 23 deletions

View File

@@ -7,10 +7,13 @@ import { dirname } from 'path';
import { fileURLToPath } from 'url';
import stream from 'stream';
import { promisify } from 'util';
import packageJson from '../../package.json' assert { type: 'json' };
const pipeline = promisify(stream.pipeline);
const changelogFile = resolve(dirname(fileURLToPath(import.meta.url)), '../../CHANGELOG.md');
const baseDir = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
const fullChangelogFile = resolve(baseDir, 'CHANGELOG.md');
const versionChangelogFile = resolve(baseDir, `CHANGELOG-${packageJson.version}.md`);
const changelogStream = conventionalChangelog({
preset: 'angular',
@@ -24,13 +27,16 @@ const changelogStream = conventionalChangelog({
process.exit(1);
});
// We need to duplicate the stream here to pipe the changelog into two separate files
const stream1 = new stream.PassThrough();
const stream2 = new stream.PassThrough();
changelogStream.pipe(stream1);
changelogStream.pipe(stream2);
await pipeline(stream1, createWriteStream(versionChangelogFile));
// Since we can't read and write from the same file at the same time,
// we use a temporary file to output the updated changelog to.
const tmpFile = createTempFile();
await pipeline(
changelogStream,
addStream(createReadStream(changelogFile)),
createWriteStream(tmpFile),
);
await pipeline(createReadStream(tmpFile), createWriteStream(changelogFile));
await pipeline(stream2, addStream(createReadStream(fullChangelogFile)), createWriteStream(tmpFile)),
await pipeline(createReadStream(tmpFile), createWriteStream(fullChangelogFile));