release-please 13.2.0 → 13.3.2

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,42 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.3.2](https://github.com/googleapis/release-please/compare/v13.3.1...v13.3.2) (2022-01-13)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * BranchName.parse should not throw exceptions ([#1227](https://github.com/googleapis/release-please/issues/1227)) ([364f1ac](https://github.com/googleapis/release-please/commit/364f1ac996b0120820d9bb37db96bb27a79aa936))
13
+ * initial release version should respect Release-As commit ([#1222](https://github.com/googleapis/release-please/issues/1222)) ([22b9770](https://github.com/googleapis/release-please/commit/22b977028e2959aea088c09e3a021e2aa0e10f03))
14
+ * Release-As commits should appear in the changelog correctly ([#1220](https://github.com/googleapis/release-please/issues/1220)) ([ab56c82](https://github.com/googleapis/release-please/commit/ab56c82e81091cbedeb8f328451ac486d7f986a4))
15
+ * use latest Release-As commit when overriding version ([#1224](https://github.com/googleapis/release-please/issues/1224)) ([2d7cb8f](https://github.com/googleapis/release-please/commit/2d7cb8fa329d1c60b881bc0435523b81ea47a32d))
16
+
17
+ ### [13.3.1](https://github.com/googleapis/release-please/compare/v13.3.0...v13.3.1) (2022-01-12)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * pass target_commitish instead of sha ([#1219](https://github.com/googleapis/release-please/issues/1219)) ([3f26ec3](https://github.com/googleapis/release-please/commit/3f26ec3de527497d7180f2cd987983c6ae6e44cd))
23
+
24
+ ## [13.3.0](https://github.com/googleapis/release-please/compare/v13.2.1...v13.3.0) (2022-01-12)
25
+
26
+
27
+ ### Features
28
+
29
+ * allow configuring simple strategy version file ([#1168](https://github.com/googleapis/release-please/issues/1168)) ([08a0cf2](https://github.com/googleapis/release-please/commit/08a0cf2b2135713f856d8621cffa8f5b92fb8699))
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * ruby-yoshi strategy should put commit summary only in pull request body ([#1193](https://github.com/googleapis/release-please/issues/1193)) ([d29eda1](https://github.com/googleapis/release-please/commit/d29eda172597979cea5cb54ce6eb278a1dfb03a0)), closes [#1192](https://github.com/googleapis/release-please/issues/1192)
35
+
36
+ ### [13.2.1](https://github.com/googleapis/release-please/compare/v13.2.0...v13.2.1) (2022-01-12)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **php-yoshi:** fix parsing of pull request body ([#1213](https://github.com/googleapis/release-please/issues/1213)) ([00702ca](https://github.com/googleapis/release-please/commit/00702ca575e5d134505280b436e1348eccb2de01))
42
+
7
43
  ## [13.2.0](https://github.com/googleapis/release-please/compare/v13.1.1...v13.2.0) (2022-01-11)
8
44
 
9
45
 
@@ -52,13 +52,16 @@ class DefaultChangelogNotes {
52
52
  subject: commit.bareMessage,
53
53
  type: commit.type,
54
54
  scope: commit.scope,
55
- notes: commit.notes,
55
+ notes: commit.notes.filter(note => note.title === 'BREAKING CHANGE'),
56
56
  references: commit.references,
57
57
  mentions: [],
58
58
  merge: null,
59
59
  revert: null,
60
60
  header: commit.message,
61
- footer: null,
61
+ footer: commit.notes
62
+ .filter(note => note.title === 'RELEASE AS')
63
+ .map(note => `Release-As: ${note.text}`)
64
+ .join('\n'),
62
65
  hash: commit.sha,
63
66
  };
64
67
  });
@@ -76,7 +76,6 @@ const releasers = {
76
76
  'php-yoshi': options => new php_yoshi_1.PHPYoshi(options),
77
77
  python: options => new python_1.Python(options),
78
78
  rust: options => new rust_1.Rust(options),
79
- simple: options => new simple_1.Simple(options),
80
79
  'terraform-module': options => new terraform_module_1.TerraformModule(options),
81
80
  helm: options => new helm_1.Helm(options),
82
81
  elixir: options => new elixir_1.Elixir(options),
@@ -159,6 +158,12 @@ async function buildStrategy(options) {
159
158
  versioningStrategy: new service_pack_1.ServicePackVersioningStrategy(),
160
159
  });
161
160
  }
161
+ case 'simple': {
162
+ return new simple_1.Simple({
163
+ ...strategyOptions,
164
+ versionFile: options.versionFile,
165
+ });
166
+ }
162
167
  default: {
163
168
  const builder = releasers[options.releaseType];
164
169
  if (builder) {
@@ -304,9 +304,9 @@ class GitHub {
304
304
  repo: this.repository.repo,
305
305
  tag_name: release.tag.toString(),
306
306
  body: release.notes,
307
- sha: release.sha,
308
307
  draft: !!options.draft,
309
308
  prerelease: !!options.prerelease,
309
+ target_commitish: release.sha,
310
310
  });
311
311
  return {
312
312
  name: resp.data.name || undefined,
@@ -9,6 +9,7 @@ import { Version, VersionsMap } from '../version';
9
9
  import { TagName } from '../util/tag-name';
10
10
  import { Release } from '../release';
11
11
  import { ReleasePullRequest } from '../release-pull-request';
12
+ import { PullRequestBody } from '../util/pull-request-body';
12
13
  import { PullRequest } from '../pull-request';
13
14
  export interface BuildUpdatesOptions {
14
15
  changelogEntry: string;
@@ -80,6 +81,7 @@ export declare abstract class BaseStrategy implements Strategy {
80
81
  */
81
82
  protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
82
83
  protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
84
+ protected buildPullRequestBody(component: string | undefined, newVersion: Version, releaseNotesBody: string, _conventionalCommits: ConventionalCommit[], _latestRelease?: Release): Promise<PullRequestBody>;
83
85
  /**
84
86
  * Builds a candidate release pull request
85
87
  * @param {Commit[]} commits Raw commits to consider for this release.
@@ -97,6 +99,7 @@ export declare abstract class BaseStrategy implements Strategy {
97
99
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
98
100
  protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
99
101
  protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
102
+ protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
100
103
  /**
101
104
  * Given a merged pull request, build the candidate release.
102
105
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -96,6 +96,15 @@ class BaseStrategy {
96
96
  changelogSections: this.changelogSections,
97
97
  });
98
98
  }
99
+ async buildPullRequestBody(component, newVersion, releaseNotesBody, _conventionalCommits, _latestRelease) {
100
+ return new pull_request_body_1.PullRequestBody([
101
+ {
102
+ component,
103
+ version: newVersion,
104
+ notes: releaseNotesBody,
105
+ },
106
+ ]);
107
+ }
99
108
  /**
100
109
  * Builds a candidate release pull request
101
110
  * @param {Commit[]} commits Raw commits to consider for this release.
@@ -131,13 +140,7 @@ class BaseStrategy {
131
140
  latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
132
141
  });
133
142
  const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion)));
134
- const pullRequestBody = new pull_request_body_1.PullRequestBody([
135
- {
136
- component,
137
- version: newVersion,
138
- notes: releaseNotesBody,
139
- },
140
- ]);
143
+ const pullRequestBody = await this.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease);
141
144
  return {
142
145
  title: pullRequestTitle,
143
146
  body: pullRequestBody,
@@ -178,16 +181,24 @@ class BaseStrategy {
178
181
  logger_1.logger.warn(`Setting version for ${this.path} from release-as configuration`);
179
182
  return version_1.Version.parse(this.releaseAs);
180
183
  }
181
- else if (latestRelease) {
182
- return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
184
+ const releaseAsCommit = conventionalCommits.find(conventionalCommit => conventionalCommit.notes.find(note => note.title === 'RELEASE AS'));
185
+ if (releaseAsCommit) {
186
+ const note = releaseAsCommit.notes.find(note => note.title === 'RELEASE AS');
187
+ if (note) {
188
+ return version_1.Version.parse(note.text);
189
+ }
183
190
  }
184
- else {
185
- return this.initialReleaseVersion();
191
+ if (latestRelease) {
192
+ return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
186
193
  }
194
+ return this.initialReleaseVersion();
187
195
  }
188
196
  async buildVersionsMap(_conventionalCommits) {
189
197
  return new Map();
190
198
  }
199
+ async parsePullRequestBody(pullRequestBody) {
200
+ return pull_request_body_1.PullRequestBody.parse(pullRequestBody);
201
+ }
191
202
  /**
192
203
  * Given a merged pull request, build the candidate release.
193
204
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -213,7 +224,7 @@ class BaseStrategy {
213
224
  logger_1.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
214
225
  return;
215
226
  }
216
- const pullRequestBody = pull_request_body_1.PullRequestBody.parse(mergedPullRequest.body);
227
+ const pullRequestBody = await this.parsePullRequestBody(mergedPullRequest.body);
217
228
  if (!pullRequestBody) {
218
229
  logger_1.logger.error('Could not parse pull request body as a release PR');
219
230
  return;
@@ -3,8 +3,10 @@ import { Update } from '../update';
3
3
  import { Commit } from '../commit';
4
4
  import { Release } from '../release';
5
5
  import { ReleasePullRequest } from '../release-pull-request';
6
+ import { PullRequestBody } from '../util/pull-request-body';
6
7
  export declare class PHPYoshi extends BaseStrategy {
7
8
  constructor(options: BaseStrategyOptions);
8
9
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
10
+ protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
9
11
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
10
12
  }
@@ -146,6 +146,23 @@ class PHPYoshi extends base_1.BaseStrategy {
146
146
  draft: draft !== null && draft !== void 0 ? draft : false,
147
147
  };
148
148
  }
149
+ async parsePullRequestBody(pullRequestBody) {
150
+ const body = pull_request_body_1.PullRequestBody.parse(pullRequestBody);
151
+ if (!body) {
152
+ return undefined;
153
+ }
154
+ const component = await this.getComponent();
155
+ const notes = body.releaseData
156
+ .map(release => {
157
+ var _a;
158
+ return `<details><summary>${release.component}: ${(_a = release.version) === null || _a === void 0 ? void 0 : _a.toString()}</summary>\n\n${release.notes}\n</details>`;
159
+ })
160
+ .join('\n\n');
161
+ return new pull_request_body_1.PullRequestBody([{ component, notes }], {
162
+ footer: body.footer,
163
+ header: body.header,
164
+ });
165
+ }
149
166
  async buildUpdates(options) {
150
167
  const updates = [];
151
168
  const version = options.newVersion;
@@ -3,7 +3,7 @@ import { ConventionalCommit } from '../commit';
3
3
  import { Update } from '../update';
4
4
  import { Release } from '../release';
5
5
  import { Version } from '../version';
6
- import { TagName } from '../util/tag-name';
6
+ import { PullRequestBody } from '../util/pull-request-body';
7
7
  interface RubyYoshiStrategyOptions extends BaseStrategyOptions {
8
8
  versionFile?: string;
9
9
  }
@@ -12,6 +12,6 @@ export declare class RubyYoshi extends BaseStrategy {
12
12
  constructor(options: RubyYoshiStrategyOptions);
13
13
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
14
14
  protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
15
- protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
15
+ protected buildPullRequestBody(component: string | undefined, newVersion: Version, releaseNotesBody: string, conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<PullRequestBody>;
16
16
  }
17
17
  export {};
@@ -24,6 +24,7 @@ const fs_1 = require("fs");
24
24
  const path_1 = require("path");
25
25
  const manifest_1 = require("../manifest");
26
26
  const logger_1 = require("../util/logger");
27
+ const pull_request_body_1 = require("../util/pull-request-body");
27
28
  const CHANGELOG_SECTIONS = [
28
29
  { type: 'feat', section: 'Features' },
29
30
  { type: 'fix', section: 'Bug Fixes' },
@@ -79,10 +80,9 @@ class RubyYoshi extends base_1.BaseStrategy {
79
80
  });
80
81
  return commits;
81
82
  }
82
- async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
83
- const releaseNotes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease);
83
+ async buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease) {
84
84
  if (!latestRelease) {
85
- return releaseNotes;
85
+ return await super.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease);
86
86
  }
87
87
  // summarize the commits that landed:
88
88
  let summary = '### Commits since last release:\n\n';
@@ -114,7 +114,15 @@ class RubyYoshi extends base_1.BaseStrategy {
114
114
  summary += `${file}\n`;
115
115
  });
116
116
  summary += `</code></pre>\n[Compare Changes](https://github.com/${repoUrl}/compare/${latestRelease.sha}...HEAD)\n`;
117
- return releaseNotes + `\n---\n${summary}`;
117
+ return new pull_request_body_1.PullRequestBody([
118
+ {
119
+ component,
120
+ version: newVersion,
121
+ notes: releaseNotesBody,
122
+ },
123
+ ], {
124
+ extra: summary,
125
+ });
118
126
  }
119
127
  }
120
128
  exports.RubyYoshi = RubyYoshi;
@@ -1,5 +1,11 @@
1
- import { BaseStrategy, BuildUpdatesOptions } from './base';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  import { Update } from '../update';
3
+ interface SimpleStrategyOptions extends BaseStrategyOptions {
4
+ versionFile?: string;
5
+ }
3
6
  export declare class Simple extends BaseStrategy {
7
+ readonly versionFile: string;
8
+ constructor(options: SimpleStrategyOptions);
4
9
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
5
10
  }
11
+ export {};
@@ -20,6 +20,11 @@ const changelog_1 = require("../updaters/changelog");
20
20
  const base_1 = require("./base");
21
21
  const default_1 = require("../updaters/default");
22
22
  class Simple extends base_1.BaseStrategy {
23
+ constructor(options) {
24
+ var _a;
25
+ super(options);
26
+ this.versionFile = (_a = options.versionFile) !== null && _a !== void 0 ? _a : 'version.txt';
27
+ }
23
28
  async buildUpdates(options) {
24
29
  const updates = [];
25
30
  const version = options.newVersion;
@@ -32,7 +37,7 @@ class Simple extends base_1.BaseStrategy {
32
37
  }),
33
38
  });
34
39
  updates.push({
35
- path: this.addPath('version.txt'),
40
+ path: this.addPath(this.versionFile),
36
41
  createIfMissing: false,
37
42
  updater: new default_1.DefaultUpdater({
38
43
  version,
@@ -15,6 +15,7 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.BranchName = void 0;
17
17
  const version_1 = require("../version");
18
+ const logger_1 = require("./logger");
18
19
  // cannot import from '..' - transpiled code references to RELEASE_PLEASE
19
20
  // at the script level are undefined, they are only defined inside function
20
21
  // or instance methods/properties.
@@ -32,13 +33,19 @@ function getAllResourceNames() {
32
33
  class BranchName {
33
34
  constructor(_branchName) { }
34
35
  static parse(branchName) {
35
- const branchNameClass = getAllResourceNames().find(clazz => {
36
- return clazz.matches(branchName);
37
- });
38
- if (!branchNameClass) {
36
+ try {
37
+ const branchNameClass = getAllResourceNames().find(clazz => {
38
+ return clazz.matches(branchName);
39
+ });
40
+ if (!branchNameClass) {
41
+ return undefined;
42
+ }
43
+ return new branchNameClass(branchName);
44
+ }
45
+ catch (e) {
46
+ logger_1.logger.warn(`Error parsing branch name: ${branchName}`, e);
39
47
  return undefined;
40
48
  }
41
- return new branchNameClass(branchName);
42
49
  }
43
50
  static ofComponentVersion(branchPrefix, version) {
44
51
  return new AutoreleaseBranchName(`release-${branchPrefix}-v${version}`);
@@ -2,10 +2,12 @@ import { Version } from '../version';
2
2
  interface PullRequestBodyOptions {
3
3
  header?: string;
4
4
  footer?: string;
5
+ extra?: string;
5
6
  }
6
7
  export declare class PullRequestBody {
7
8
  header: string;
8
9
  footer: string;
10
+ extra?: string;
9
11
  releaseData: ReleaseData[];
10
12
  constructor(releaseData: ReleaseData[], options?: PullRequestBodyOptions);
11
13
  static parse(body: string): PullRequestBody | undefined;
@@ -24,6 +24,7 @@ class PullRequestBody {
24
24
  constructor(releaseData, options) {
25
25
  this.header = (options === null || options === void 0 ? void 0 : options.header) || DEFAULT_HEADER;
26
26
  this.footer = (options === null || options === void 0 ? void 0 : options.footer) || DEFAULT_FOOTER;
27
+ this.extra = options === null || options === void 0 ? void 0 : options.extra;
27
28
  this.releaseData = releaseData;
28
29
  }
29
30
  static parse(body) {
@@ -63,7 +64,7 @@ ${NOTES_DELIMITER}
63
64
 
64
65
  ${notes}
65
66
 
66
- ${NOTES_DELIMITER}
67
+ ${NOTES_DELIMITER}${this.extra ? `\n\n${this.extra}\n` : ''}
67
68
  ${this.footer}`;
68
69
  }
69
70
  }
@@ -87,7 +88,7 @@ function splitBody(body) {
87
88
  content,
88
89
  };
89
90
  }
90
- const SUMMARY_PATTERN = /^(?<component>.*): (?<version>\d+\.\d+\.\d+.*)$/;
91
+ const SUMMARY_PATTERN = /^(?<component>.*[^:]):? (?<version>\d+\.\d+\.\d+.*)$/;
91
92
  function extractMultipleReleases(notes) {
92
93
  const data = [];
93
94
  const root = node_html_parser_1.parse(notes);
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.DefaultVersioningStrategy = void 0;
17
17
  const versioning_strategy_1 = require("../versioning-strategy");
18
18
  const version_1 = require("../version");
19
+ const logger_1 = require("../util/logger");
19
20
  /**
20
21
  * This is the default VersioningStrategy for release-please. Breaking
21
22
  * changes should bump the major, features should bump the minor, and other
@@ -48,11 +49,12 @@ class DefaultVersioningStrategy {
48
49
  // iterate through list of commits and find biggest commit type
49
50
  let breaking = 0;
50
51
  let features = 0;
51
- let customVersion;
52
52
  for (const commit of commits) {
53
53
  const releaseAs = commit.notes.find(note => note.title === 'RELEASE AS');
54
54
  if (releaseAs) {
55
- customVersion = version_1.Version.parse(releaseAs.text);
55
+ // commits are handled newest to oldest, so take the first one (newest) found
56
+ logger_1.logger.debug(`found Release-As: ${releaseAs.text}, forcing version`);
57
+ return new versioning_strategy_1.CustomVersionUpdate(version_1.Version.parse(releaseAs.text).toString());
56
58
  }
57
59
  if (commit.breaking) {
58
60
  breaking++;
@@ -61,9 +63,6 @@ class DefaultVersioningStrategy {
61
63
  features++;
62
64
  }
63
65
  }
64
- if (customVersion) {
65
- return new versioning_strategy_1.CustomVersionUpdate(customVersion.toString());
66
- }
67
66
  if (breaking > 0) {
68
67
  if (version.major < 1 && this.bumpMinorPreMajor) {
69
68
  return new versioning_strategy_1.MinorVersionUpdate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.2.0",
3
+ "version": "13.3.2",
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",
@@ -41,7 +41,7 @@
41
41
  "@types/chai": "^4.1.7",
42
42
  "@types/iarna__toml": "^2.0.1",
43
43
  "@types/js-yaml": "^4.0.0",
44
- "@types/mocha": "^8.0.0",
44
+ "@types/mocha": "^9.0.0",
45
45
  "@types/node": "^16.0.0",
46
46
  "@types/pino": "^7.0.0",
47
47
  "@types/semver": "^7.0.0",
@@ -51,7 +51,7 @@
51
51
  "chai": "^4.2.0",
52
52
  "cross-env": "^7.0.0",
53
53
  "gts": "^3.0.0",
54
- "mocha": "^8.0.0",
54
+ "mocha": "^9.0.0",
55
55
  "nock": "^13.0.0",
56
56
  "sinon": "12.0.1",
57
57
  "snap-shot-it": "^7.0.0"