1
1
import { publish_flags_config } from '../../utils/flags-config' ;
2
2
import { parseRawFlags } from '../../utils/parse-args' ;
3
- import { getGitState } from '../../utils/git' ;
3
+ import { GIT_TAG , getAllPackagesForGitTag , getGitState } from '../../utils/git' ;
4
4
import { printHelpDocs } from '../../help/docs' ;
5
5
import { bumpAllPackages , restorePackagesForDryRun } from './steps/bump-versions' ;
6
6
import { generatePackageTarballs } from './steps/generate-tarballs' ;
7
7
import { printStrategy } from './steps/print-strategy' ;
8
- import { applyStrategy } from './steps/generate-strategy' ;
8
+ import { AppliedStrategy , applyStrategy } from './steps/generate-strategy' ;
9
9
import { confirmStrategy } from './steps/confirm-strategy' ;
10
10
import { publishPackages } from './steps/publish-packages' ;
11
11
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' ;
12
16
13
17
export async function executePublish ( args : string [ ] ) {
14
18
// get user supplied config
@@ -26,25 +30,34 @@ export async function executePublish(args: string[]) {
26
30
// get configured strategy
27
31
const strategy = await loadStrategy ( ) ;
28
32
29
- // get packages
33
+ // get packages present on our current branch
30
34
const packages = await gatherPackages ( strategy . config ) ;
31
35
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
+
32
41
// get applied strategy
33
- const applied = await applyStrategy ( config . full , strategy , packages ) ;
42
+ const applied = await applyStrategy ( config . full , strategy , baseVersionPackages , packages ) ;
34
43
35
44
// print strategy to be applied
36
45
await printStrategy ( config . full , applied ) ;
37
46
38
47
await confirmStrategy ( ) ;
39
48
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
+ }
48
61
49
62
// Bump package.json versions & commit/tag
50
63
// ========================
0 commit comments