Skip to content

Commit 8b2626e

Browse files
committed
chore: add changelog generation in release mode.
1 parent ac076b0 commit 8b2626e

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

release/core/publish/index.ts

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { publish_flags_config } from '../../utils/flags-config';
22
import { parseRawFlags } from '../../utils/parse-args';
3-
import { getGitState } from '../../utils/git';
3+
import { GIT_TAG, getAllPackagesForGitTag, getGitState } from '../../utils/git';
44
import { printHelpDocs } from '../../help/docs';
55
import { bumpAllPackages, restorePackagesForDryRun } from './steps/bump-versions';
66
import { generatePackageTarballs } from './steps/generate-tarballs';
77
import { printStrategy } from './steps/print-strategy';
8-
import { applyStrategy } from './steps/generate-strategy';
8+
import { AppliedStrategy, applyStrategy } from './steps/generate-strategy';
99
import { confirmStrategy } from './steps/confirm-strategy';
1010
import { publishPackages } from './steps/publish-packages';
1111
import { gatherPackages, loadStrategy } from '../../utils/package';
12+
import { CHANNEL, SEMVER_VERSION } from '../../utils/channel';
13+
import { confirmCommitChangelogs } from '../release-notes/steps/confirm-changelogs';
14+
import { updateChangelogs } from '../release-notes/steps/update-changelogs';
15+
import { getChanges } from '../release-notes/steps/get-changes';
1216

1317
export async function executePublish(args: string[]) {
1418
// get user supplied config
@@ -26,25 +30,34 @@ export async function executePublish(args: string[]) {
2630
// get configured strategy
2731
const strategy = await loadStrategy();
2832

29-
// get packages
33+
// get packages present on our current branch
3034
const packages = await gatherPackages(strategy.config);
3135

36+
// get packages present in the git tag version
37+
const fromVersion = config.full.get('from') as SEMVER_VERSION | undefined;
38+
const fromTag = `v${fromVersion}` as GIT_TAG;
39+
const baseVersionPackages = fromVersion ? await getAllPackagesForGitTag(fromTag) : packages;
40+
3241
// get applied strategy
33-
const applied = await applyStrategy(config.full, strategy, packages);
42+
const applied = await applyStrategy(config.full, strategy, baseVersionPackages, packages);
3443

3544
// print strategy to be applied
3645
await printStrategy(config.full, applied);
3746

3847
await confirmStrategy();
3948

40-
// TODO: Generate Release Notes / PR flow?
41-
// Ideally we do per-package changelogs + a root changelog thats rolls up
42-
// those changes into one set of release notes.
43-
// this step probably would create an artifact like .changelog.json
44-
// and open a PR, and then early exit. Then if the script is run again
45-
// it would check if the PR is merged and if so it would continue.
46-
// await generateReleaseNotes(config, packages, applied.public_pks);
47-
// await confirmReleaseNotesMerged();
49+
const channel = config.full.get('channel') as CHANNEL;
50+
if (channel !== 'canary' && channel !== 'beta') {
51+
// generate the list of changes
52+
const newChanges = await getChanges(strategy, packages, fromTag);
53+
54+
// update all changelogs, including the primary changelog
55+
// and the changelogs for each package in changelogRoots
56+
// this will not commit the changes
57+
const changedFiles = await updateChangelogs(fromTag, newChanges, config.full, strategy, packages, applied);
58+
59+
await confirmCommitChangelogs(changedFiles, config.full, applied);
60+
}
4861

4962
// Bump package.json versions & commit/tag
5063
// ========================

release/core/release-notes/steps/confirm-changelogs.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BunFile } from 'bun';
22
import { confirm } from '../../publish/steps/confirm-strategy';
33
import { exec } from '../../../utils/cmd';
4-
import { SEMVER_VERSION } from '../../../utils/channel';
54
import chalk from 'chalk';
65
import { AppliedStrategy } from '../../publish/steps/generate-strategy';
76

release/utils/flags-config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ export const publish_flags_config: FlagConfig = {
152152
}
153153
},
154154
},
155-
commit_changelog: {
155+
commit: {
156156
name: 'Commit',
157-
flag: 'commit_changelog',
157+
flag: 'commit',
158158
flag_aliases: ['c'],
159-
flag_mispellings: ['cm', 'comit', 'changelog'],
159+
flag_mispellings: ['cm', 'comit', 'changelog', 'commit_changelog'],
160160
description: 'Whether to commit the changes to the changelogs',
161161
type: Boolean,
162162
examples: [],

0 commit comments

Comments
 (0)