mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
ci: Update changelog generation to work with node 18
This commit is contained in:
parent
1438a737b3
commit
5b99f1e177
1
.github/scripts/package.json
vendored
1
.github/scripts/package.json
vendored
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"add-stream": "^1.0.0",
|
||||
"conventional-changelog": "^4.0.0",
|
||||
"glob": "^10.3.0",
|
||||
"semver": "^7.5.4",
|
||||
|
|
19
.github/scripts/update-changelog.mjs
vendored
19
.github/scripts/update-changelog.mjs
vendored
|
@ -1,16 +1,12 @@
|
|||
import addStream from 'add-stream';
|
||||
import createTempFile from 'tempfile';
|
||||
import conventionalChangelog from 'conventional-changelog';
|
||||
import { resolve } from 'path';
|
||||
import { createReadStream, createWriteStream } from 'fs';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import stream from 'stream';
|
||||
import { promisify } from 'util';
|
||||
import { pipeline } from 'stream/promises';
|
||||
import packageJson from '../../package.json' assert { type: 'json' };
|
||||
|
||||
const pipeline = promisify(stream.pipeline);
|
||||
|
||||
const baseDir = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
|
||||
const fullChangelogFile = resolve(baseDir, 'CHANGELOG.md');
|
||||
const versionChangelogFile = resolve(baseDir, `CHANGELOG-${packageJson.version}.md`);
|
||||
|
@ -27,16 +23,13 @@ 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));
|
||||
// Write the new changelog to a new temporary file, so that the contents can be used in the PR description
|
||||
await pipeline(changelogStream, 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(stream2, addStream(createReadStream(fullChangelogFile)), createWriteStream(tmpFile)),
|
||||
const tmpStream = createWriteStream(tmpFile);
|
||||
await pipeline(createReadStream(versionChangelogFile), tmpStream, { end: false });
|
||||
await pipeline(createReadStream(fullChangelogFile), tmpStream);
|
||||
await pipeline(createReadStream(tmpFile), createWriteStream(fullChangelogFile));
|
||||
|
|
Loading…
Reference in a new issue