Skip to content

Commit b565f85

Browse files
authored
feat!: strategies can parse multiple releases from single release PR (googleapis#1775)
* feat!: strategies can parse multiple releases from single release PR * docs: add deprecation doc to buildRelease() * chore: fix lint
1 parent 3391d3b commit b565f85

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

src/manifest.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,19 +1054,19 @@ export class Manifest {
10541054

10551055
// Find merged release pull requests
10561056
const generator = await this.findMergedReleasePullRequests();
1057-
const releases: CandidateRelease[] = [];
1057+
const candidateReleases: CandidateRelease[] = [];
10581058
for await (const pullRequest of generator) {
10591059
for (const path in this.repositoryConfig) {
10601060
const config = this.repositoryConfig[path];
10611061
this.logger.info(`Building release for path: ${path}`);
10621062
this.logger.debug(`type: ${config.releaseType}`);
10631063
this.logger.debug(`targetBranch: ${this.targetBranch}`);
10641064
const strategy = strategiesByPath[path];
1065-
const release = await strategy.buildRelease(pullRequest, {
1065+
const releases = await strategy.buildReleases(pullRequest, {
10661066
groupPullRequestTitlePattern: this.groupPullRequestTitlePattern,
10671067
});
1068-
if (release) {
1069-
releases.push({
1068+
for (const release of releases) {
1069+
candidateReleases.push({
10701070
...release,
10711071
path,
10721072
pullRequest,
@@ -1076,13 +1076,11 @@ export class Manifest {
10761076
(!!release.tag.version.preRelease ||
10771077
release.tag.version.major === 0),
10781078
});
1079-
} else {
1080-
this.logger.info(`No release necessary for path: ${path}`);
10811079
}
10821080
}
10831081
}
10841082

1085-
return releases;
1083+
return candidateReleases;
10861084
}
10871085

10881086
/**

src/strategies/base.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ export abstract class BaseStrategy implements Strategy {
496496
* Given a merged pull request, build the candidate release.
497497
* @param {PullRequest} mergedPullRequest The merged release pull request.
498498
* @returns {Release} The candidate release.
499+
* @deprecated Use buildReleases() instead.
499500
*/
500501
async buildRelease(
501502
mergedPullRequest: PullRequest,
@@ -613,6 +614,22 @@ export abstract class BaseStrategy implements Strategy {
613614
};
614615
}
615616

617+
/**
618+
* Given a merged pull request, build the candidate releases.
619+
* @param {PullRequest} mergedPullRequest The merged release pull request.
620+
* @returns {Release} The candidate release.
621+
*/
622+
async buildReleases(
623+
mergedPullRequest: PullRequest,
624+
options?: BuildReleaseOptions
625+
): Promise<Release[]> {
626+
const release = await this.buildRelease(mergedPullRequest, options);
627+
if (release) {
628+
return [release];
629+
}
630+
return [];
631+
}
632+
616633
isPublishedVersion(_version: Version): boolean {
617634
return true;
618635
}

src/strategy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,23 @@ export interface Strategy {
5454
* Given a merged pull request, build the candidate release.
5555
* @param {PullRequest} mergedPullRequest The merged release pull request.
5656
* @returns {Release} The candidate release.
57+
* @deprecated Use buildReleases() instead.
5758
*/
5859
buildRelease(
5960
mergedPullRequest: PullRequest,
6061
options?: BuildReleaseOptions
6162
): Promise<Release | undefined>;
6263

64+
/**
65+
* Given a merged pull request, build the candidate releases.
66+
* @param {PullRequest} mergedPullRequest The merged release pull request.
67+
* @returns {Release} The candidate release.
68+
*/
69+
buildReleases(
70+
mergedPullRequest: PullRequest,
71+
options?: BuildReleaseOptions
72+
): Promise<Release[]>;
73+
6374
/**
6475
* Return the component for this strategy. This may be a computed field.
6576
* @returns {string}

0 commit comments

Comments
 (0)