release-please 17.7.0 → 17.9.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.
Files changed (45) hide show
  1. package/build/src/factory.js +4 -0
  2. package/build/src/github-api.d.ts +1 -1
  3. package/build/src/github.d.ts +1 -1
  4. package/build/src/github.js +1 -1
  5. package/build/src/index.d.ts +1 -1
  6. package/build/src/index.js +1 -1
  7. package/build/src/local-github.d.ts +1 -1
  8. package/build/src/local-github.js +1 -1
  9. package/build/src/plugins/linked-versions.js +1 -1
  10. package/build/src/strategies/go-librarian.d.ts +9 -0
  11. package/build/src/strategies/go-librarian.js +70 -0
  12. package/build/src/strategies/java-yoshi-mono-repo.js +1 -1
  13. package/build/src/strategies/node-librarian.js +1 -1
  14. package/build/src/strategies/python-librarian.d.ts +6 -0
  15. package/build/src/strategies/python-librarian.js +35 -0
  16. package/build/src/updaters/go/version-go.js +1 -1
  17. package/build/src/updaters/{node/librarian-yaml.d.ts → librarian-yaml.d.ts} +16 -7
  18. package/build/src/updaters/librarian-yaml.js +120 -0
  19. package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
  20. package/build/src/util/code-suggester/default-options-handler.js +45 -0
  21. package/build/src/util/code-suggester/errors.d.ts +4 -0
  22. package/build/src/util/code-suggester/errors.js +24 -0
  23. package/build/src/util/code-suggester/github/branch.d.ts +45 -0
  24. package/build/src/util/code-suggester/github/branch.js +118 -0
  25. package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
  26. package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
  27. package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
  28. package/build/src/util/code-suggester/github/create-commit.js +60 -0
  29. package/build/src/util/code-suggester/github/fork.d.ts +15 -0
  30. package/build/src/util/code-suggester/github/fork.js +48 -0
  31. package/build/src/util/code-suggester/github/labels.d.ts +14 -0
  32. package/build/src/util/code-suggester/github/labels.js +42 -0
  33. package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
  34. package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
  35. package/build/src/util/code-suggester/index.d.ts +28 -0
  36. package/build/src/util/code-suggester/index.js +110 -0
  37. package/build/src/util/code-suggester/logger.d.ts +4 -0
  38. package/build/src/util/code-suggester/logger.js +37 -0
  39. package/build/src/util/code-suggester/types.d.ts +109 -0
  40. package/build/src/util/code-suggester/types.js +30 -0
  41. package/build/src/util/pull-request-title.js +4 -4
  42. package/package.json +3 -2
  43. package/build/src/updaters/java/librarian-yaml.d.ts +0 -29
  44. package/build/src/updaters/java/librarian-yaml.js +0 -81
  45. package/build/src/updaters/node/librarian-yaml.js +0 -73
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.createPullRequest = void 0;
17
+ const logger_1 = require("./logger");
18
+ const default_options_handler_1 = require("./default-options-handler");
19
+ const retry = require("async-retry");
20
+ const branch_1 = require("./github/branch");
21
+ const fork_1 = require("./github/fork");
22
+ const commit_and_push_1 = require("./github/commit-and-push");
23
+ const open_pull_request_1 = require("./github/open-pull-request");
24
+ const labels_1 = require("./github/labels");
25
+ /**
26
+ * Make a new GitHub Pull Request with a set of changes applied on top of primary branch HEAD.
27
+ * The changes are committed into a new branch based on the upstream repository options using the authenticated Octokit account.
28
+ * Then a Pull Request is made from that branch.
29
+ *
30
+ * Also throws error if git data from the fork is not ready in 5 minutes.
31
+ *
32
+ * From the docs
33
+ * https://developer.github.com/v3/repos/forks/#create-a-fork
34
+ * """
35
+ * Forking a Repository happens asynchronously.
36
+ * You may have to wait a short period of time before you can access the git objects.
37
+ * If this takes longer than 5 minutes, be sure to contact GitHub Support or GitHub Premium Support.
38
+ * """
39
+ *
40
+ * If changes are empty then the workflow will not run.
41
+ * Rethrows an HttpError if Octokit GitHub API returns an error. HttpError Octokit access_token and client_secret headers redact all sensitive information.
42
+ * @param {Octokit} octokit The authenticated octokit instance, instantiated with an access token having permissiong to create a fork on the target repository
43
+ * @param {Changes | null | undefined} changes A set of changes. The changes may be empty
44
+ * @param {CreatePullRequestUserOptions} options The configuration for interacting with GitHub provided by the user.
45
+ * @returns {Promise<number>} the pull request number. Returns 0 if unsuccessful.
46
+ * @throws {CommitError} on failure during commit process
47
+ */
48
+ async function createPullRequest(octokit, changes, options) {
49
+ (0, logger_1.setupLogger)(options.logger);
50
+ // if null undefined, or the empty map then no changes have been provided.
51
+ // Do not execute GitHub workflow
52
+ if (changes === null || changes === undefined || changes.size === 0) {
53
+ logger_1.logger.info('Empty change set provided. No changes need to be made. Cancelling workflow.');
54
+ return 0;
55
+ }
56
+ const gitHubConfigs = (0, default_options_handler_1.addPullRequestDefaults)(options);
57
+ logger_1.logger.info('Starting GitHub PR workflow...');
58
+ const upstream = {
59
+ owner: gitHubConfigs.upstreamOwner,
60
+ repo: gitHubConfigs.upstreamRepo,
61
+ };
62
+ const origin = options.fork === false ? upstream : await (0, fork_1.fork)(octokit, upstream);
63
+ if (options.fork) {
64
+ // try to sync the fork
65
+ await retry(async () => await octokit.repos.mergeUpstream({
66
+ owner: origin.owner,
67
+ repo: origin.repo,
68
+ branch: gitHubConfigs.primary,
69
+ }), {
70
+ retries: options.retry,
71
+ factor: 2.8411,
72
+ minTimeout: 3000,
73
+ randomize: false,
74
+ onRetry: (e, attempt) => {
75
+ e.message = `Error creating syncing upstream: ${e.message}`;
76
+ logger_1.logger.error(e);
77
+ logger_1.logger.info(`Retry attempt #${attempt}...`);
78
+ },
79
+ });
80
+ }
81
+ const originBranch = {
82
+ ...origin,
83
+ branch: gitHubConfigs.branch,
84
+ };
85
+ // The `retry` flag defaults to `5` to maintain compatibility
86
+ options.retry = options.retry === undefined ? 5 : options.retry;
87
+ const refHeadSha = await retry(async () => await (0, branch_1.branch)(octokit, origin, upstream, originBranch.branch, gitHubConfigs.primary), {
88
+ retries: options.retry,
89
+ factor: 2.8411,
90
+ minTimeout: 3000,
91
+ randomize: false,
92
+ onRetry: (e, attempt) => {
93
+ e.message = `Error creating Pull Request: ${e.message}`;
94
+ logger_1.logger.error(e);
95
+ logger_1.logger.info(`Retry attempt #${attempt}...`);
96
+ },
97
+ });
98
+ await (0, commit_and_push_1.commitAndPush)(octokit, refHeadSha, changes, originBranch, gitHubConfigs.message, gitHubConfigs.force, options);
99
+ const description = {
100
+ body: gitHubConfigs.description,
101
+ title: gitHubConfigs.title,
102
+ };
103
+ const prNumber = await (0, open_pull_request_1.openPullRequest)(octokit, upstream, originBranch, description, gitHubConfigs.maintainersCanModify, gitHubConfigs.primary, options.draft);
104
+ logger_1.logger.info(`Successfully opened pull request: ${prNumber}.`);
105
+ // addLabels will no-op if options.labels is undefined or empty.
106
+ await (0, labels_1.addLabels)(octokit, upstream, originBranch, prNumber, options.labels);
107
+ return prNumber;
108
+ }
109
+ exports.createPullRequest = createPullRequest;
110
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import { Logger } from './types';
2
+ declare let logger: Logger;
3
+ declare function setupLogger(userLogger?: Logger): void;
4
+ export { logger, setupLogger };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.setupLogger = exports.logger = void 0;
17
+ class NullLogger {
18
+ constructor() {
19
+ this.error = () => { };
20
+ this.warn = () => { };
21
+ this.info = () => { };
22
+ this.debug = () => { };
23
+ this.trace = () => { };
24
+ }
25
+ }
26
+ let logger = new NullLogger();
27
+ exports.logger = logger;
28
+ function setupLogger(userLogger) {
29
+ if (userLogger) {
30
+ exports.logger = logger = userLogger;
31
+ }
32
+ else {
33
+ exports.logger = logger = new NullLogger();
34
+ }
35
+ }
36
+ exports.setupLogger = setupLogger;
37
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1,109 @@
1
+ import { CreateCommitOptions } from './github/create-commit';
2
+ export type FileMode = '100644' | '100755' | '040000' | '160000' | '120000';
3
+ /**
4
+ * GitHub definition of tree
5
+ */
6
+ export interface TreeObject {
7
+ path: string;
8
+ mode: FileMode;
9
+ type: 'blob' | 'tree' | 'commit';
10
+ sha?: string | null;
11
+ content?: string;
12
+ }
13
+ /**
14
+ * The content and the mode of a file.
15
+ * Default file mode is a text file which has code '100644'.
16
+ * If `content` is not null, then `content` must be the entire file content.
17
+ * See https://developer.github.com/v3/git/trees/#tree-object for details on mode.
18
+ */
19
+ export declare class FileData {
20
+ readonly mode: FileMode;
21
+ readonly content: string | null;
22
+ constructor(content: string | null, mode?: FileMode);
23
+ }
24
+ /**
25
+ * The map of a path to its content data.
26
+ * The content must be the entire file content.
27
+ */
28
+ export type Changes = Map<string, FileData>;
29
+ /**
30
+ * The domain of a repository
31
+ */
32
+ export interface RepoDomain {
33
+ repo: string;
34
+ owner: string;
35
+ }
36
+ /**
37
+ * The domain for a branch
38
+ */
39
+ export interface BranchDomain extends RepoDomain {
40
+ branch: string;
41
+ }
42
+ /**
43
+ * The descriptive properties for any entity
44
+ */
45
+ export interface Description {
46
+ title: string;
47
+ body: string;
48
+ }
49
+ /**
50
+ * The user options for creating GitHub PRs
51
+ */
52
+ export interface CreatePullRequestUserOptions extends CreateCommitOptions {
53
+ upstreamOwner: string;
54
+ upstreamRepo: string;
55
+ message: string;
56
+ description: string;
57
+ title: string;
58
+ branch?: string;
59
+ force?: boolean;
60
+ fork?: boolean;
61
+ primary?: string;
62
+ maintainersCanModify?: boolean;
63
+ labels?: string[];
64
+ retry?: number;
65
+ draft?: boolean;
66
+ logger?: Logger;
67
+ filesPerCommit?: number;
68
+ }
69
+ /**
70
+ * GitHub data needed for creating a PR
71
+ */
72
+ export interface CreatePullRequest {
73
+ upstreamOwner: string;
74
+ upstreamRepo: string;
75
+ message: string;
76
+ description: string;
77
+ title: string;
78
+ branch: string;
79
+ force: boolean;
80
+ primary: string;
81
+ maintainersCanModify: boolean;
82
+ filesPerCommit?: number;
83
+ }
84
+ interface LogFn {
85
+ <T extends object>(obj: T, msg?: string, ...args: any[]): void;
86
+ (msg: string, ...args: any[]): void;
87
+ }
88
+ export interface Logger {
89
+ error: LogFn;
90
+ warn: LogFn;
91
+ info: LogFn;
92
+ debug: LogFn;
93
+ trace: LogFn;
94
+ }
95
+ export interface UserData {
96
+ name: string;
97
+ email: string;
98
+ }
99
+ export interface CommitData {
100
+ message: string;
101
+ tree: string;
102
+ parents: string[];
103
+ author?: UserData;
104
+ committer?: UserData;
105
+ }
106
+ export interface CommitSigner {
107
+ generateSignature(commit: CommitData): Promise<string>;
108
+ }
109
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.FileData = void 0;
17
+ /**
18
+ * The content and the mode of a file.
19
+ * Default file mode is a text file which has code '100644'.
20
+ * If `content` is not null, then `content` must be the entire file content.
21
+ * See https://developer.github.com/v3/git/trees/#tree-object for details on mode.
22
+ */
23
+ class FileData {
24
+ constructor(content, mode = '100644') {
25
+ this.mode = mode;
26
+ this.content = content;
27
+ }
28
+ }
29
+ exports.FileData = FileData;
30
+ //# sourceMappingURL=types.js.map
@@ -32,10 +32,10 @@ function generateMatchPattern(pullRequestTitlePattern, componentNoSpace, logger
32
32
  pullRequestTitlePattern.search(/\$\{version\}/) === -1)
33
33
  logger.warn("pullRequestTitlePattern miss the part of '${version}'");
34
34
  return new RegExp(`^${(pullRequestTitlePattern || DEFAULT_PR_TITLE_PATTERN)
35
- .replace('[', '\\[') // TODO: handle all regex escaping
36
- .replace(']', '\\]')
37
- .replace('(', '\\(')
38
- .replace(')', '\\)')
35
+ .replace(/\[/g, '\\[') // TODO: handle all regex escaping
36
+ .replace(/\]/g, '\\]')
37
+ .replace(/\(/g, '\\(')
38
+ .replace(/\)/g, '\\)')
39
39
  .replace('${scope}', '(\\((?<branch>[\\w-./]+)\\))?')
40
40
  .replace('${component}', componentNoSpace === true
41
41
  ? '?(?<component>@?[\\w-./]*)?'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "17.7.0",
3
+ "version": "17.9.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",
@@ -39,6 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@octokit/types": "^9.0.0",
42
+ "@types/async-retry": "^1.4.9",
42
43
  "@types/chai": "^4.1.7",
43
44
  "@types/diff": "^5.0.2",
44
45
  "@types/iarna__toml": "^2.0.1",
@@ -75,8 +76,8 @@
75
76
  "@octokit/rest": "^20.1.1",
76
77
  "@types/npm-package-arg": "^6.1.0",
77
78
  "@xmldom/xmldom": "^0.8.4",
79
+ "async-retry": "^1.3.3",
78
80
  "chalk": "^4.0.0",
79
- "code-suggester": "^5.0.0",
80
81
  "conventional-changelog-conventionalcommits": "^6.0.0",
81
82
  "conventional-changelog-writer": "^6.0.0",
82
83
  "conventional-commits-filter": "^3.0.0",
@@ -1,29 +0,0 @@
1
- import { DefaultUpdater } from '../default';
2
- import { Logger } from '../../util/logger';
3
- export interface JavaModule {
4
- artifact_id: string;
5
- [key: string]: any;
6
- }
7
- export interface LibrarianLibrary {
8
- name: string;
9
- version: string;
10
- java: JavaModule;
11
- [key: string]: any;
12
- }
13
- export interface LibrarianYamlSchema {
14
- libraries: LibrarianLibrary[];
15
- [key: string]: any;
16
- }
17
- /**
18
- * Updates a librarian.yaml file.
19
- */
20
- export declare class LibrarianYamlUpdater extends DefaultUpdater {
21
- specialArtifacts: ReadonlyMap<string, string>;
22
- /**
23
- * Given initial file contents, return updated contents.
24
- * @param {string} content The initial content
25
- * @returns {string} The updated content
26
- */
27
- updateContent(content: string, logger?: Logger): string;
28
- findArtifactID(library: LibrarianLibrary): string;
29
- }
@@ -1,81 +0,0 @@
1
- "use strict";
2
- // Copyright 2026 Google LLC
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.LibrarianYamlUpdater = void 0;
17
- const default_1 = require("../default");
18
- const yaml = require("yaml");
19
- const logger_1 = require("../../util/logger");
20
- /**
21
- * Updates a librarian.yaml file.
22
- */
23
- class LibrarianYamlUpdater extends default_1.DefaultUpdater {
24
- constructor() {
25
- super(...arguments);
26
- this.specialArtifacts = new Map([
27
- ['google-cloud-java', 'google-cloud-java'],
28
- ]);
29
- }
30
- /**
31
- * Given initial file contents, return updated contents.
32
- * @param {string} content The initial content
33
- * @returns {string} The updated content
34
- */
35
- updateContent(content, logger = logger_1.logger) {
36
- if (!this.versionsMap) {
37
- logger.warn('missing versions map');
38
- return content;
39
- }
40
- // Use yaml package to make sure librarian.yaml is not reformatted because
41
- // we use different tool to format librarian.yaml.
42
- const doc = yaml.parseDocument(content);
43
- if (!doc || doc.errors.length > 0) {
44
- logger.warn('Invalid yaml, cannot be parsed');
45
- return content;
46
- }
47
- const libraries = doc.get('libraries');
48
- if (!libraries || !yaml.isSeq(libraries)) {
49
- return content;
50
- }
51
- let modified = false;
52
- for (const library of libraries.items) {
53
- if (!yaml.isMap(library))
54
- continue;
55
- const artifactID = this.findArtifactID(library.toJSON());
56
- if (this.versionsMap.has(artifactID)) {
57
- const newVersion = this.versionsMap.get(artifactID);
58
- if (newVersion && library.get('version') !== newVersion.toString()) {
59
- library.set('version', newVersion.toString());
60
- modified = true;
61
- }
62
- }
63
- }
64
- if (modified) {
65
- return doc.toString({ lineWidth: 0 });
66
- }
67
- return content;
68
- }
69
- findArtifactID(library) {
70
- const artifact = this.specialArtifacts.get(library.name);
71
- if (artifact) {
72
- return artifact;
73
- }
74
- if (library.java && library.java.artifact_id) {
75
- return library.java.artifact_id;
76
- }
77
- return `google-cloud-${library.name}`;
78
- }
79
- }
80
- exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
81
- //# sourceMappingURL=librarian-yaml.js.map
@@ -1,73 +0,0 @@
1
- "use strict";
2
- // Copyright 2026 Google LLC
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.LibrarianYamlUpdater = void 0;
17
- const default_1 = require("../default");
18
- const yaml = require("yaml");
19
- const logger_1 = require("../../util/logger");
20
- /**
21
- * Updates a librarian.yaml file.
22
- */
23
- class LibrarianYamlUpdater extends default_1.DefaultUpdater {
24
- constructor(options) {
25
- super(options);
26
- this.packagePath = options.packagePath;
27
- }
28
- /**
29
- * Given initial file contents, return updated contents.
30
- * @param {string} content The initial content
31
- * @returns {string} The updated content
32
- */
33
- updateContent(content, logger = logger_1.logger) {
34
- // Use yaml package to make sure librarian.yaml is not reformatted because
35
- // we use different tool to format librarian.yaml.
36
- const doc = yaml.parseDocument(content);
37
- if (!doc || doc.errors.length > 0) {
38
- logger.warn('Invalid yaml, cannot be parsed');
39
- return content;
40
- }
41
- const libraries = doc.get('libraries');
42
- if (!libraries || !yaml.isSeq(libraries)) {
43
- return content;
44
- }
45
- let modified = false;
46
- for (const library of libraries.items) {
47
- if (!yaml.isMap(library))
48
- continue;
49
- // The release-please version map key is the output directory (explicit or
50
- // derived) in librarian.yaml.
51
- const outputDirectory = this.deriveOutputDirectory(library.toJSON());
52
- if (outputDirectory === this.packagePath) {
53
- const newVersion = this.version.toString();
54
- if (library.get('version') !== newVersion) {
55
- library.set('version', newVersion);
56
- modified = true;
57
- }
58
- }
59
- }
60
- if (modified) {
61
- return doc.toString({ lineWidth: 0 });
62
- }
63
- return content;
64
- }
65
- deriveOutputDirectory(library) {
66
- if (library.output) {
67
- return library.output;
68
- }
69
- return `packages/${library.name}`;
70
- }
71
- }
72
- exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
73
- //# sourceMappingURL=librarian-yaml.js.map