release-please 17.5.1 → 17.6.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/build/src/index.d.ts +1 -1
- package/build/src/index.js +1 -1
- package/build/src/local-github.d.ts +0 -1
- package/build/src/local-github.js +52 -74
- package/build/src/strategies/java-yoshi-mono-repo.js +13 -0
- package/build/src/updaters/java/librarian-yaml.d.ts +29 -0
- package/build/src/updaters/java/librarian-yaml.js +81 -0
- package/package.json +1 -1
package/build/src/index.d.ts
CHANGED
package/build/src/index.js
CHANGED
|
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
|
|
|
36
36
|
exports.configSchema = require('../../schemas/config.json');
|
|
37
37
|
exports.manifestSchema = require('../../schemas/manifest.json');
|
|
38
38
|
// x-release-please-start-version
|
|
39
|
-
exports.VERSION = '17.
|
|
39
|
+
exports.VERSION = '17.6.0';
|
|
40
40
|
// x-release-please-end
|
|
41
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -185,7 +185,6 @@ export declare class LocalGitHub implements Scm {
|
|
|
185
185
|
* @throws {GitHubAPIError} on an API error
|
|
186
186
|
*/
|
|
187
187
|
tagIterator(options?: ScmTagIteratorOptions): AsyncGenerator<ScmTag, void, void>;
|
|
188
|
-
private applyEditsAndPush;
|
|
189
188
|
/**
|
|
190
189
|
* Open a pull request
|
|
191
190
|
*
|
|
@@ -20,6 +20,7 @@ const os = require("os");
|
|
|
20
20
|
const child_process = require("child_process");
|
|
21
21
|
const util = require("util");
|
|
22
22
|
const readline = require("readline");
|
|
23
|
+
const code_suggester_1 = require("code-suggester");
|
|
23
24
|
const execFile = util.promisify(child_process.execFile);
|
|
24
25
|
const mkdtemp = fs.promises.mkdtemp;
|
|
25
26
|
const errors_1 = require("./errors");
|
|
@@ -71,8 +72,12 @@ class LocalGitHub {
|
|
|
71
72
|
logger.info(`Using existing local repository at ${repoDir}...`);
|
|
72
73
|
}
|
|
73
74
|
const branch = gitHubApi.repository.defaultBranch;
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const fetchArgs = ['fetch', 'origin'];
|
|
76
|
+
if (options.cloneDepth) {
|
|
77
|
+
fetchArgs.push('--depth', options.cloneDepth.toString());
|
|
78
|
+
}
|
|
79
|
+
logger.debug(`Executing: git ${fetchArgs.join(' ')}`);
|
|
80
|
+
await execFile('git', fetchArgs, { cwd: repoDir });
|
|
76
81
|
logger.debug(`Executing: git checkout ${branch}`);
|
|
77
82
|
await execFile('git', ['checkout', branch], { cwd: repoDir });
|
|
78
83
|
logger.debug(`Executing: git reset --hard origin/${branch}`);
|
|
@@ -536,55 +541,6 @@ class LocalGitHub {
|
|
|
536
541
|
}
|
|
537
542
|
}
|
|
538
543
|
}
|
|
539
|
-
async applyEditsAndPush(branch, targetBranch, message, changes) {
|
|
540
|
-
this.logger.debug(`Applying edits and pushing to ${branch}`);
|
|
541
|
-
// Checkout/Reset PR branch
|
|
542
|
-
await execFile('git', ['fetch', 'origin', '--', targetBranch], {
|
|
543
|
-
cwd: this.cloneDir,
|
|
544
|
-
});
|
|
545
|
-
await execFile('git', ['checkout', '-B', branch, `origin/${targetBranch}`], {
|
|
546
|
-
cwd: this.cloneDir,
|
|
547
|
-
});
|
|
548
|
-
// Write file edits
|
|
549
|
-
for (const [filePath, fileUpdate] of changes.entries()) {
|
|
550
|
-
const fullPath = path.join(this.cloneDir, filePath);
|
|
551
|
-
await fs.promises.mkdir(path.dirname(fullPath), { recursive: true });
|
|
552
|
-
if (fileUpdate.content !== null) {
|
|
553
|
-
await fs.promises.writeFile(fullPath, fileUpdate.content);
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
await fs.promises.unlink(fullPath).catch(() => { });
|
|
557
|
-
}
|
|
558
|
-
if (fileUpdate.mode) {
|
|
559
|
-
await fs.promises.chmod(fullPath, parseInt(fileUpdate.mode, 8));
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
// Commit changes
|
|
563
|
-
const msgFile = path.join(os.tmpdir(), `release-please-commit-msg-${process.pid}-${Date.now()}`);
|
|
564
|
-
await fs.promises.writeFile(msgFile, message);
|
|
565
|
-
await execFile('git', ['add', '.'], { cwd: this.cloneDir });
|
|
566
|
-
try {
|
|
567
|
-
await execFile('git', ['commit', '--no-verify', '-F', msgFile], {
|
|
568
|
-
cwd: this.cloneDir,
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
catch (err) {
|
|
572
|
-
const error = err;
|
|
573
|
-
if (error.stdout && error.stdout.includes('nothing to commit')) {
|
|
574
|
-
this.logger.debug('Nothing to commit');
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
throw err;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
finally {
|
|
581
|
-
await fs.promises.unlink(msgFile).catch(() => { });
|
|
582
|
-
}
|
|
583
|
-
// Push transit
|
|
584
|
-
await execFile('git', ['push', '--no-verify', '-f', 'origin', branch], {
|
|
585
|
-
cwd: this.cloneDir,
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
544
|
/**
|
|
589
545
|
* Open a pull request
|
|
590
546
|
*
|
|
@@ -597,9 +553,33 @@ class LocalGitHub {
|
|
|
597
553
|
*/
|
|
598
554
|
async createPullRequest(pullRequest, targetBranch, message, updates, options) {
|
|
599
555
|
const changes = await this.buildChangeSet(updates, targetBranch);
|
|
600
|
-
await
|
|
601
|
-
|
|
602
|
-
|
|
556
|
+
const prNumber = await (0, code_suggester_1.createPullRequest)(this.gitHubApi.octokit, changes, {
|
|
557
|
+
upstreamOwner: this.repository.owner,
|
|
558
|
+
upstreamRepo: this.repository.repo,
|
|
559
|
+
title: pullRequest.title,
|
|
560
|
+
branch: pullRequest.headBranchName,
|
|
561
|
+
description: pullRequest.body,
|
|
562
|
+
primary: targetBranch,
|
|
563
|
+
force: true,
|
|
564
|
+
fork: !!(options === null || options === void 0 ? void 0 : options.fork),
|
|
565
|
+
message,
|
|
566
|
+
logger: this.logger,
|
|
567
|
+
draft: !!(options === null || options === void 0 ? void 0 : options.draft),
|
|
568
|
+
labels: pullRequest.labels,
|
|
569
|
+
});
|
|
570
|
+
if (prNumber === 0) {
|
|
571
|
+
this.logger.warn('no code changes detected, skipping pull request creation');
|
|
572
|
+
return {
|
|
573
|
+
headBranchName: pullRequest.headBranchName,
|
|
574
|
+
baseBranchName: targetBranch,
|
|
575
|
+
number: 0,
|
|
576
|
+
title: pullRequest.title,
|
|
577
|
+
body: pullRequest.body,
|
|
578
|
+
labels: pullRequest.labels,
|
|
579
|
+
files: [],
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return await this.getPullRequest(prNumber);
|
|
603
583
|
}
|
|
604
584
|
/**
|
|
605
585
|
* Update a pull request's title and body.
|
|
@@ -615,31 +595,29 @@ class LocalGitHub {
|
|
|
615
595
|
async updatePullRequest(number, pullRequest, targetBranch, options) {
|
|
616
596
|
const changes = await this.buildChangeSet(pullRequest.updates, targetBranch);
|
|
617
597
|
const message = pullRequest.title.toString();
|
|
618
|
-
|
|
598
|
+
const title = pullRequest.title.toString();
|
|
619
599
|
const body = ((options === null || options === void 0 ? void 0 : options.pullRequestOverflowHandler)
|
|
620
600
|
? await options.pullRequestOverflowHandler.handleOverflow(pullRequest)
|
|
621
601
|
: pullRequest.body)
|
|
622
602
|
.toString()
|
|
623
603
|
.slice(0, github_api_1.MAX_ISSUE_BODY_SIZE);
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
body,
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
.filter((name) => !!name),
|
|
642
|
-
};
|
|
604
|
+
const prNumber = await (0, code_suggester_1.createPullRequest)(this.gitHubApi.octokit, changes, {
|
|
605
|
+
upstreamOwner: this.repository.owner,
|
|
606
|
+
upstreamRepo: this.repository.repo,
|
|
607
|
+
title,
|
|
608
|
+
branch: pullRequest.headRefName,
|
|
609
|
+
description: body,
|
|
610
|
+
primary: targetBranch,
|
|
611
|
+
force: true,
|
|
612
|
+
fork: (options === null || options === void 0 ? void 0 : options.fork) === false ? false : true,
|
|
613
|
+
message,
|
|
614
|
+
logger: this.logger,
|
|
615
|
+
draft: pullRequest.draft,
|
|
616
|
+
});
|
|
617
|
+
if (prNumber !== number) {
|
|
618
|
+
this.logger.warn(`updated code for ${prNumber}, but update requested for ${number}`);
|
|
619
|
+
}
|
|
620
|
+
return this.gitHubApi.updatePullRequest(number, title, body);
|
|
643
621
|
}
|
|
644
622
|
async getPullRequest(number) {
|
|
645
623
|
return await this.gitHubApi.getPullRequest(number);
|
|
@@ -23,6 +23,7 @@ const composite_1 = require("../updaters/composite");
|
|
|
23
23
|
const errors_1 = require("../errors");
|
|
24
24
|
const java_1 = require("./java");
|
|
25
25
|
const java_update_1 = require("../updaters/java/java-update");
|
|
26
|
+
const librarian_yaml_1 = require("../updaters/java/librarian-yaml");
|
|
26
27
|
const filter_commits_1 = require("../util/filter-commits");
|
|
27
28
|
class JavaYoshiMonoRepo extends java_1.Java {
|
|
28
29
|
/**
|
|
@@ -87,6 +88,7 @@ class JavaYoshiMonoRepo extends java_1.Java {
|
|
|
87
88
|
const dependenciesSearch = this.github.findFilesByFilenameAndRef('dependencies.properties', this.targetBranch, this.path);
|
|
88
89
|
const readmeFilesSearch = this.github.findFilesByFilenameAndRef('README.md', this.targetBranch, this.path);
|
|
89
90
|
const versionFilesSearch = this.github.findFilesByFilenameAndRef('Version.java', this.targetBranch, this.path);
|
|
91
|
+
const librarianFilesSearch = this.github.findFilesByFilenameAndRef('librarian.yaml', this.targetBranch, this.path);
|
|
90
92
|
const pomFiles = await pomFilesSearch;
|
|
91
93
|
pomFiles.forEach(path => {
|
|
92
94
|
updates.push({
|
|
@@ -147,6 +149,17 @@ class JavaYoshiMonoRepo extends java_1.Java {
|
|
|
147
149
|
}),
|
|
148
150
|
});
|
|
149
151
|
});
|
|
152
|
+
const librarianFiles = await librarianFilesSearch;
|
|
153
|
+
librarianFiles.forEach(path => {
|
|
154
|
+
updates.push({
|
|
155
|
+
path: this.addPath(path),
|
|
156
|
+
createIfMissing: false,
|
|
157
|
+
updater: new librarian_yaml_1.LibrarianYamlUpdater({
|
|
158
|
+
version,
|
|
159
|
+
versionsMap,
|
|
160
|
+
}),
|
|
161
|
+
});
|
|
162
|
+
});
|
|
150
163
|
this.extraFiles.forEach(extraFile => {
|
|
151
164
|
if (typeof extraFile === 'object') {
|
|
152
165
|
return;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DefaultUpdater } from '../default';
|
|
2
|
+
import { Logger } from '../../util/logger';
|
|
3
|
+
export interface JavaModule {
|
|
4
|
+
distribution_name_override: 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
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.distribution_name_override) {
|
|
75
|
+
return library.java.distribution_name_override.split(':')[1];
|
|
76
|
+
}
|
|
77
|
+
return `google-cloud-${library.name}`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
|
|
81
|
+
//# sourceMappingURL=librarian-yaml.js.map
|