From 41d2e64a3ab650b751d711dc5b559c2f5357aa02 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 19 Nov 2024 14:31:55 -0500 Subject: [PATCH] ci(scripts): remove updating changelog.md --- scripts/release.ts | 9 ++----- ...teChangelog.ts => generateReleaseNotes.ts} | 25 ++++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) rename scripts/utils/{updateChangelog.ts => generateReleaseNotes.ts} (90%) diff --git a/scripts/release.ts b/scripts/release.ts index 382cd34de..8cf1854d7 100755 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -16,8 +16,8 @@ import type { PackageDetails } from './lib/getPackageDetails.js' import { getPackageDetails } from './lib/getPackageDetails.js' import { getPackageRegistryVersions } from './lib/getPackageRegistryVersions.js' import { packagePublishList } from './lib/publishList.js' +import { generateReleaseNotes } from './utils/generateReleaseNotes.js' import { getRecommendedBump } from './utils/getRecommendedBump.js' -import { updateChangelog } from './utils/updateChangelog.js' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -124,17 +124,12 @@ async function main() { // Preview/Update changelog header(`${logPrefix}📝 Updating changelog...`) - const { - changelog: changelogContent, - releaseNotes, - releaseUrl, - } = await updateChangelog({ + const { changelog: changelogContent, releaseUrl } = await generateReleaseNotes({ bump, dryRun, toVersion: 'HEAD', fromVersion, openReleaseUrl: true, - writeChangelog: changelog, }) console.log(chalk.green('\nChangelog Preview:\n')) diff --git a/scripts/utils/updateChangelog.ts b/scripts/utils/generateReleaseNotes.ts similarity index 90% rename from scripts/utils/updateChangelog.ts rename to scripts/utils/generateReleaseNotes.ts index bc89e5a23..b77826b5c 100755 --- a/scripts/utils/updateChangelog.ts +++ b/scripts/utils/generateReleaseNotes.ts @@ -15,7 +15,6 @@ type Args = { bump?: 'major' | 'minor' | 'patch' | 'prerelease' dryRun?: boolean openReleaseUrl?: boolean - writeChangelog?: boolean } type ChangelogResult = { @@ -33,8 +32,8 @@ type ChangelogResult = { releaseNotes: string } -export const updateChangelog = async (args: Args = {}): Promise => { - const { toVersion = 'HEAD', dryRun, bump, openReleaseUrl, writeChangelog } = args +export const generateReleaseNotes = async (args: Args = {}): Promise => { + const { toVersion = 'HEAD', dryRun, bump, openReleaseUrl } = args const fromVersion = args.fromVersion || execSync('git describe --match "v*" --tags --abbrev=0').toString().trim() @@ -111,14 +110,6 @@ export const updateChangelog = async (args: Args = {}): Promise changelog += `### ⚠️ BREAKING CHANGES\n\n${stringifiedSections.breaking.join('\n')}\n\n` } - if (writeChangelog) { - const changelogPath = 'CHANGELOG.md' - const existingChangelog = await fse.readFile(changelogPath, 'utf8') - const newChangelog = changelog + '\n\n' + existingChangelog - await fse.writeFile(changelogPath, newChangelog) - console.log(`Changelog updated at ${changelogPath}`) - } - // Add contributors after writing to file const releaseNotes = changelog + contributors @@ -234,10 +225,14 @@ function formatCommitForChangelog(commit: GitCommit, includeBreakingNotes = fals // module import workaround for ejs if (import.meta.url === `file://${process.argv[1]}`) { // This module is being run directly - const { fromVersion, toVersion, bump, openReleaseUrl, writeChangelog } = minimist( - process.argv.slice(2), - ) - updateChangelog({ bump, fromVersion, toVersion, dryRun: false, openReleaseUrl, writeChangelog }) + const { fromVersion, toVersion, bump, openReleaseUrl } = minimist(process.argv.slice(2)) + generateReleaseNotes({ + bump, + fromVersion, + toVersion, + dryRun: false, + openReleaseUrl, + }) .then(() => { console.log('Done') })