ci(scripts): remove updating changelog.md
This commit is contained in:
@@ -16,8 +16,8 @@ import type { PackageDetails } from './lib/getPackageDetails.js'
|
|||||||
import { getPackageDetails } from './lib/getPackageDetails.js'
|
import { getPackageDetails } from './lib/getPackageDetails.js'
|
||||||
import { getPackageRegistryVersions } from './lib/getPackageRegistryVersions.js'
|
import { getPackageRegistryVersions } from './lib/getPackageRegistryVersions.js'
|
||||||
import { packagePublishList } from './lib/publishList.js'
|
import { packagePublishList } from './lib/publishList.js'
|
||||||
|
import { generateReleaseNotes } from './utils/generateReleaseNotes.js'
|
||||||
import { getRecommendedBump } from './utils/getRecommendedBump.js'
|
import { getRecommendedBump } from './utils/getRecommendedBump.js'
|
||||||
import { updateChangelog } from './utils/updateChangelog.js'
|
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
@@ -124,17 +124,12 @@ async function main() {
|
|||||||
|
|
||||||
// Preview/Update changelog
|
// Preview/Update changelog
|
||||||
header(`${logPrefix}📝 Updating changelog...`)
|
header(`${logPrefix}📝 Updating changelog...`)
|
||||||
const {
|
const { changelog: changelogContent, releaseUrl } = await generateReleaseNotes({
|
||||||
changelog: changelogContent,
|
|
||||||
releaseNotes,
|
|
||||||
releaseUrl,
|
|
||||||
} = await updateChangelog({
|
|
||||||
bump,
|
bump,
|
||||||
dryRun,
|
dryRun,
|
||||||
toVersion: 'HEAD',
|
toVersion: 'HEAD',
|
||||||
fromVersion,
|
fromVersion,
|
||||||
openReleaseUrl: true,
|
openReleaseUrl: true,
|
||||||
writeChangelog: changelog,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(chalk.green('\nChangelog Preview:\n'))
|
console.log(chalk.green('\nChangelog Preview:\n'))
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ type Args = {
|
|||||||
bump?: 'major' | 'minor' | 'patch' | 'prerelease'
|
bump?: 'major' | 'minor' | 'patch' | 'prerelease'
|
||||||
dryRun?: boolean
|
dryRun?: boolean
|
||||||
openReleaseUrl?: boolean
|
openReleaseUrl?: boolean
|
||||||
writeChangelog?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChangelogResult = {
|
type ChangelogResult = {
|
||||||
@@ -33,8 +32,8 @@ type ChangelogResult = {
|
|||||||
releaseNotes: string
|
releaseNotes: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateChangelog = async (args: Args = {}): Promise<ChangelogResult> => {
|
export const generateReleaseNotes = async (args: Args = {}): Promise<ChangelogResult> => {
|
||||||
const { toVersion = 'HEAD', dryRun, bump, openReleaseUrl, writeChangelog } = args
|
const { toVersion = 'HEAD', dryRun, bump, openReleaseUrl } = args
|
||||||
|
|
||||||
const fromVersion =
|
const fromVersion =
|
||||||
args.fromVersion || execSync('git describe --match "v*" --tags --abbrev=0').toString().trim()
|
args.fromVersion || execSync('git describe --match "v*" --tags --abbrev=0').toString().trim()
|
||||||
@@ -111,14 +110,6 @@ export const updateChangelog = async (args: Args = {}): Promise<ChangelogResult>
|
|||||||
changelog += `### ⚠️ BREAKING CHANGES\n\n${stringifiedSections.breaking.join('\n')}\n\n`
|
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
|
// Add contributors after writing to file
|
||||||
const releaseNotes = changelog + contributors
|
const releaseNotes = changelog + contributors
|
||||||
|
|
||||||
@@ -234,10 +225,14 @@ function formatCommitForChangelog(commit: GitCommit, includeBreakingNotes = fals
|
|||||||
// module import workaround for ejs
|
// module import workaround for ejs
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
// This module is being run directly
|
// This module is being run directly
|
||||||
const { fromVersion, toVersion, bump, openReleaseUrl, writeChangelog } = minimist(
|
const { fromVersion, toVersion, bump, openReleaseUrl } = minimist(process.argv.slice(2))
|
||||||
process.argv.slice(2),
|
generateReleaseNotes({
|
||||||
)
|
bump,
|
||||||
updateChangelog({ bump, fromVersion, toVersion, dryRun: false, openReleaseUrl, writeChangelog })
|
fromVersion,
|
||||||
|
toVersion,
|
||||||
|
dryRun: false,
|
||||||
|
openReleaseUrl,
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('Done')
|
console.log('Done')
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user