release-please 13.3.2 → 13.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [13.4.0](https://github.com/googleapis/release-please/compare/v13.3.2...v13.4.0) (2022-01-18)
8
+
9
+
10
+ ### Features
11
+
12
+ * add grouped manifest pr title pattern option ([#1184](https://github.com/googleapis/release-please/issues/1184)) ([df1332f](https://github.com/googleapis/release-please/commit/df1332f3b95e622752d351a29fc0a1b5083963c6))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **go-yoshi:** restore scope-based commit filtering ([#1233](https://github.com/googleapis/release-please/issues/1233)) ([597e6dd](https://github.com/googleapis/release-please/commit/597e6dd58217c62d562070032138cee8cad5e693))
18
+ * search for files on target branch, not default branch ([#1235](https://github.com/googleapis/release-please/issues/1235)) ([d891f00](https://github.com/googleapis/release-please/commit/d891f000eb2b198bfb4331b41bc5020fff52e1da))
19
+
7
20
  ### [13.3.2](https://github.com/googleapis/release-please/compare/v13.3.1...v13.3.2) (2022-01-13)
8
21
 
9
22
 
@@ -71,6 +71,7 @@ export interface ManifestOptions {
71
71
  draft?: boolean;
72
72
  prerelease?: boolean;
73
73
  draftPullRequest?: boolean;
74
+ groupPullRequestTitlePattern?: string;
74
75
  }
75
76
  interface ReleaserPackageConfig extends ReleaserConfigJson {
76
77
  'package-name'?: string;
@@ -88,6 +89,7 @@ export interface ManifestConfig extends ReleaserConfigJson {
88
89
  'always-link-local'?: boolean;
89
90
  plugins?: PluginType[];
90
91
  'separate-pull-requests'?: boolean;
92
+ 'group-pull-request-title-pattern'?: string;
91
93
  }
92
94
  export declare type ReleasedVersions = Record<string, Version>;
93
95
  export declare type RepositoryConfig = Record<string, ReleaserConfig>;
@@ -122,6 +124,7 @@ export declare class Manifest {
122
124
  private draft?;
123
125
  private prerelease?;
124
126
  private draftPullRequest?;
127
+ private groupPullRequestTitlePattern?;
125
128
  /**
126
129
  * Create a Manifest from explicit config in code. This assumes that the
127
130
  * repository has a single component at the root path.
@@ -77,6 +77,7 @@ class Manifest {
77
77
  this.lastReleaseSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.lastReleaseSha;
78
78
  this.draft = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draft;
79
79
  this.draftPullRequest = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draftPullRequest;
80
+ this.groupPullRequestTitlePattern = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.groupPullRequestTitlePattern;
80
81
  }
81
82
  /**
82
83
  * Create a Manifest from config files in the repository.
@@ -314,7 +315,7 @@ class Manifest {
314
315
  // Combine pull requests into 1 unless configured for separate
315
316
  // pull requests
316
317
  if (!this.separatePullRequests) {
317
- plugins.push(new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig));
318
+ plugins.push(new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, this.groupPullRequestTitlePattern));
318
319
  }
319
320
  for (const plugin of plugins) {
320
321
  newReleasePullRequests = await plugin.run(newReleasePullRequests);
@@ -588,6 +589,7 @@ async function parseConfig(github, configFile, branch) {
588
589
  lastReleaseSha: config['last-release-sha'],
589
590
  alwaysLinkLocal: config['always-link-local'],
590
591
  separatePullRequests: config['separate-pull-requests'],
592
+ groupPullRequestTitlePattern: config['group-pull-request-title-pattern'],
591
593
  plugins: config['plugins'],
592
594
  };
593
595
  return { config: repositoryConfig, options: manifestOptions };
@@ -701,7 +703,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit
701
703
  return candidateTagVersion.sort((a, b) => b.compare(a))[0];
702
704
  }
703
705
  function mergeReleaserConfig(defaultConfig, pathConfig) {
704
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
706
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
705
707
  return {
706
708
  releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
707
709
  bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
@@ -716,6 +718,7 @@ function mergeReleaserConfig(defaultConfig, pathConfig) {
716
718
  packageName: (_m = pathConfig.packageName) !== null && _m !== void 0 ? _m : defaultConfig.packageName,
717
719
  versionFile: (_o = pathConfig.versionFile) !== null && _o !== void 0 ? _o : defaultConfig.versionFile,
718
720
  extraFiles: (_p = pathConfig.extraFiles) !== null && _p !== void 0 ? _p : defaultConfig.extraFiles,
721
+ pullRequestTitlePattern: (_q = pathConfig.pullRequestTitlePattern) !== null && _q !== void 0 ? _q : defaultConfig.pullRequestTitlePattern,
719
722
  };
720
723
  }
721
724
  /**
@@ -1,5 +1,6 @@
1
1
  import { ManifestPlugin } from '../plugin';
2
- import { CandidateReleasePullRequest } from '../manifest';
2
+ import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
3
+ import { GitHub } from '../github';
3
4
  /**
4
5
  * This plugin merges multiple pull requests into a single
5
6
  * release pull request.
@@ -7,5 +8,7 @@ import { CandidateReleasePullRequest } from '../manifest';
7
8
  * Release notes are broken up using `<summary>`/`<details>` blocks.
8
9
  */
9
10
  export declare class Merge extends ManifestPlugin {
11
+ private pullRequestTitlePattern?;
12
+ constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, pullRequestTitlePattern?: string);
10
13
  run(candidates: CandidateReleasePullRequest[]): Promise<CandidateReleasePullRequest[]>;
11
14
  }
@@ -27,6 +27,11 @@ const composite_1 = require("../updaters/composite");
27
27
  * Release notes are broken up using `<summary>`/`<details>` blocks.
28
28
  */
29
29
  class Merge extends plugin_1.ManifestPlugin {
30
+ constructor(github, targetBranch, repositoryConfig, pullRequestTitlePattern) {
31
+ super(github, targetBranch, repositoryConfig);
32
+ this.pullRequestTitlePattern =
33
+ pullRequestTitlePattern || manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN;
34
+ }
30
35
  async run(candidates) {
31
36
  if (candidates.length < 1) {
32
37
  return candidates;
@@ -34,6 +39,7 @@ class Merge extends plugin_1.ManifestPlugin {
34
39
  const releaseData = [];
35
40
  const labels = new Set();
36
41
  let rawUpdates = [];
42
+ let rootRelease = null;
37
43
  for (const candidate of candidates) {
38
44
  const pullRequest = candidate.pullRequest;
39
45
  rawUpdates = rawUpdates.concat(...pullRequest.updates);
@@ -41,10 +47,13 @@ class Merge extends plugin_1.ManifestPlugin {
41
47
  labels.add(label);
42
48
  }
43
49
  releaseData.push(...pullRequest.body.releaseData);
50
+ if (candidate.path === '.') {
51
+ rootRelease = candidate;
52
+ }
44
53
  }
45
54
  const updates = composite_1.mergeUpdates(rawUpdates);
46
55
  const pullRequest = {
47
- title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN),
56
+ title: pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.component, this.targetBranch, rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.version, this.pullRequestTitlePattern),
48
57
  body: new pull_request_body_1.PullRequestBody(releaseData),
49
58
  updates,
50
59
  labels: Array.from(labels),
@@ -55,7 +55,7 @@ export declare abstract class BaseStrategy implements Strategy {
55
55
  protected tagSeparator?: string;
56
56
  private skipGitHubRelease;
57
57
  private releaseAs?;
58
- private includeComponentInTag;
58
+ protected includeComponentInTag: boolean;
59
59
  private pullRequestTitlePattern?;
60
60
  readonly extraFiles: string[];
61
61
  readonly changelogNotes: ChangelogNotes;
@@ -79,7 +79,7 @@ export declare abstract class BaseStrategy implements Strategy {
79
79
  * @param {ConventionalCommit[]} commits parsed commits
80
80
  * @returns {ConventionalCommit[]} modified commits
81
81
  */
82
- protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
82
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
83
83
  protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
84
84
  protected buildPullRequestBody(component: string | undefined, newVersion: Version, releaseNotesBody: string, _conventionalCommits: ConventionalCommit[], _latestRelease?: Release): Promise<PullRequestBody>;
85
85
  /**
@@ -81,7 +81,7 @@ class BaseStrategy {
81
81
  * @param {ConventionalCommit[]} commits parsed commits
82
82
  * @returns {ConventionalCommit[]} modified commits
83
83
  */
84
- postProcessCommits(commits) {
84
+ async postProcessCommits(commits) {
85
85
  return commits;
86
86
  }
87
87
  async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
@@ -117,13 +117,14 @@ class BaseStrategy {
117
117
  * open a pull request.
118
118
  */
119
119
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
120
- const conventionalCommits = this.postProcessCommits(commit_1.parseConventionalCommits(commits));
120
+ const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
121
+ logger_1.logger.info(`Considering: ${conventionalCommits.length} commits`);
121
122
  const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
122
123
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
123
124
  const component = await this.getComponent();
124
125
  logger_1.logger.debug('component:', component);
125
126
  const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator);
126
- logger_1.logger.warn('pull request title pattern:', this.pullRequestTitlePattern);
127
+ logger_1.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
127
128
  const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern);
128
129
  const branchName = component
129
130
  ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
@@ -7,7 +7,7 @@ import { Release } from '../release';
7
7
  export declare class GoYoshi extends BaseStrategy {
8
8
  constructor(options: BaseStrategyOptions);
9
9
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
10
- protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
10
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
11
11
  protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
12
12
  protected initialReleaseVersion(): Version;
13
13
  }
@@ -18,6 +18,7 @@ const base_1 = require("./base");
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  const version_1 = require("../version");
20
20
  const version_go_1 = require("../updaters/go/version-go");
21
+ const logger_1 = require("../util/logger");
21
22
  // Commits containing a scope prefixed with an item in this array will be
22
23
  // ignored when generating a release PR for the parent module.
23
24
  const IGNORED_SUB_MODULES = new Set([
@@ -59,8 +60,10 @@ class GoYoshi extends base_1.BaseStrategy {
59
60
  });
60
61
  return updates;
61
62
  }
62
- postProcessCommits(commits) {
63
+ async postProcessCommits(commits) {
63
64
  let regenCommit;
65
+ const component = await this.getComponent();
66
+ logger_1.logger.debug('Filtering commits');
64
67
  return commits.filter(commit => {
65
68
  var _a, _b;
66
69
  // ignore commits whose scope is in the list of ignored modules
@@ -97,6 +100,37 @@ class GoYoshi extends base_1.BaseStrategy {
97
100
  }
98
101
  }
99
102
  }
103
+ // For google-cloud-go, filter into 2 cases, a subset of modules
104
+ // released independently, and the remainder
105
+ if (this.repository.owner === 'googleapis' &&
106
+ this.repository.repo === 'google-cloud-go') {
107
+ // Skip commits that don't have a scope as we don't know where to
108
+ // put them
109
+ if (!commit.scope) {
110
+ logger_1.logger.debug(`Skipping commit without scope: ${commit.message}`);
111
+ return false;
112
+ }
113
+ // Skip commits related to sub-modules as they are not part of
114
+ // the parent module.
115
+ if (this.includeComponentInTag) {
116
+ // This is a submodule release, so only include commits in this
117
+ // scope
118
+ if (!commitMatchesScope(commit.scope, component)) {
119
+ logger_1.logger.debug(`Skipping commit scope: ${commit.scope} != ${component}`);
120
+ return false;
121
+ }
122
+ }
123
+ else {
124
+ // This is the main module release, so ignore sub modules that
125
+ // are released independently
126
+ for (const submodule of IGNORED_SUB_MODULES) {
127
+ if (commitMatchesScope(commit.scope, submodule)) {
128
+ logger_1.logger.debug(`Skipping ignored commit scope: ${commit.scope}`);
129
+ return false;
130
+ }
131
+ }
132
+ }
133
+ }
100
134
  return true;
101
135
  });
102
136
  }
@@ -111,4 +145,7 @@ class GoYoshi extends base_1.BaseStrategy {
111
145
  }
112
146
  }
113
147
  exports.GoYoshi = GoYoshi;
148
+ function commitMatchesScope(commitScope, scope) {
149
+ return commitScope === scope || commitScope.startsWith(`${scope}/`);
150
+ }
114
151
  //# sourceMappingURL=go-yoshi.js.map
@@ -136,9 +136,9 @@ class JavaYoshi extends base_1.BaseStrategy {
136
136
  versionsMap,
137
137
  }),
138
138
  });
139
- const pomFilesSearch = this.github.findFilesByFilename('pom.xml', this.path);
140
- const buildFilesSearch = this.github.findFilesByFilename('build.gradle', this.path);
141
- const dependenciesSearch = this.github.findFilesByFilename('dependencies.properties', this.path);
139
+ const pomFilesSearch = this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path);
140
+ const buildFilesSearch = this.github.findFilesByFilenameAndRef('build.gradle', this.targetBranch, this.path);
141
+ const dependenciesSearch = this.github.findFilesByFilenameAndRef('dependencies.properties', this.targetBranch, this.path);
142
142
  const pomFiles = await pomFilesSearch;
143
143
  pomFiles.forEach(path => {
144
144
  updates.push({
@@ -50,7 +50,7 @@ class PHPYoshi extends base_1.BaseStrategy {
50
50
  }
51
51
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
52
52
  var _a, _b, _c;
53
- const conventionalCommits = this.postProcessCommits(commit_1.parseConventionalCommits(commits));
53
+ const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
54
54
  const newVersion = latestRelease
55
55
  ? await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits)
56
56
  : this.initialReleaseVersion();
@@ -87,7 +87,7 @@ class Python extends base_1.BaseStrategy {
87
87
  });
88
88
  }
89
89
  // There should be only one version.py, but foreach in case that is incorrect
90
- const versionPyFilesSearch = this.github.findFilesByFilename('version.py', this.path);
90
+ const versionPyFilesSearch = this.github.findFilesByFilenameAndRef('version.py', this.targetBranch, this.path);
91
91
  const versionPyFiles = await versionPyFilesSearch;
92
92
  versionPyFiles.forEach(path => {
93
93
  updates.push({
@@ -11,7 +11,7 @@ export declare class RubyYoshi extends BaseStrategy {
11
11
  readonly versionFile: string;
12
12
  constructor(options: RubyYoshiStrategyOptions);
13
13
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
14
- protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
14
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
15
15
  protected buildPullRequestBody(component: string | undefined, newVersion: Version, releaseNotesBody: string, conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<PullRequestBody>;
16
16
  }
17
17
  export {};
@@ -74,7 +74,7 @@ class RubyYoshi extends base_1.BaseStrategy {
74
74
  });
75
75
  return updates;
76
76
  }
77
- postProcessCommits(commits) {
77
+ async postProcessCommits(commits) {
78
78
  commits.forEach(commit => {
79
79
  commit.message = indent_commit_1.indentCommit(commit);
80
80
  });
@@ -8,6 +8,6 @@ export declare class Ruby extends BaseStrategy {
8
8
  readonly versionFile: string;
9
9
  constructor(options: RubyStrategyOptions);
10
10
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
11
- protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
11
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
12
12
  }
13
13
  export {};
@@ -50,7 +50,7 @@ class Ruby extends base_1.BaseStrategy {
50
50
  });
51
51
  return updates;
52
52
  }
53
- postProcessCommits(commits) {
53
+ async postProcessCommits(commits) {
54
54
  commits.forEach(commit => {
55
55
  commit.message = indent_commit_1.indentCommit(commit);
56
56
  });
@@ -35,7 +35,7 @@ class TerraformModule extends base_1.BaseStrategy {
35
35
  });
36
36
  // Update version in README to current candidate version.
37
37
  // A module may have submodules, so find all submodules.
38
- const readmeFiles = await this.github.findFilesByFilename('readme.md', this.path);
38
+ const readmeFiles = await this.github.findFilesByFilenameAndRef('readme.md', this.targetBranch, this.path);
39
39
  readmeFiles.forEach(path => {
40
40
  updates.push({
41
41
  path: this.addPath(path),
@@ -48,8 +48,8 @@ class TerraformModule extends base_1.BaseStrategy {
48
48
  // Update versions.tf to current candidate version.
49
49
  // A module may have submodules, so find all versions.tfand versions.tf.tmpl to update.
50
50
  const versionFiles = await Promise.all([
51
- this.github.findFilesByFilename('versions.tf', this.path),
52
- this.github.findFilesByFilename('versions.tf.tmpl', this.path),
51
+ this.github.findFilesByFilenameAndRef('versions.tf', this.targetBranch, this.path),
52
+ this.github.findFilesByFilenameAndRef('versions.tf.tmpl', this.targetBranch, this.path),
53
53
  ]).then(([v, vt]) => {
54
54
  return v.concat(vt);
55
55
  });
@@ -11,7 +11,7 @@ export declare class PullRequestTitle {
11
11
  static ofComponentVersion(component: string, version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
12
12
  static ofVersion(version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
13
13
  static ofTargetBranchVersion(targetBranch: string, version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
14
- static ofComponentTargetBranchVersion(component: string, targetBranch: string, version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
14
+ static ofComponentTargetBranchVersion(component?: string, targetBranch?: string, version?: Version, pullRequestTitlePattern?: string): PullRequestTitle;
15
15
  static ofTargetBranch(targetBranch: string, pullRequestTitlePattern?: string): PullRequestTitle;
16
16
  getTargetBranch(): string | undefined;
17
17
  getComponent(): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.3.2",
3
+ "version": "13.4.0",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",
@@ -79,7 +79,7 @@
79
79
  "node-html-parser": "^5.0.0",
80
80
  "parse-github-repo-url": "^1.4.1",
81
81
  "semver": "^7.0.0",
82
- "type-fest": "^1.0.0",
82
+ "type-fest": "^2.0.0",
83
83
  "typescript": "^3.8.3",
84
84
  "unist-util-visit": "^2.0.3",
85
85
  "unist-util-visit-parents": "^3.1.1",