From 158269cb94671f2314f9356118dd014addfba029 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Tue, 19 Jan 2021 12:37:12 -0800 Subject: [PATCH] feat(dev-infra): automatically add labels to release PRs (#40016) Automatically add provided labels to PRs created for release. PR Close #40016 --- .ng-dev/release.ts | 2 -- dev-infra/ng-dev.js | 4 ++++ dev-infra/release/config/index.ts | 2 ++ dev-infra/release/publish/actions.ts | 9 +++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.ng-dev/release.ts b/.ng-dev/release.ts index d896fc9adb..8177c3c3e1 100644 --- a/.ng-dev/release.ts +++ b/.ng-dev/release.ts @@ -32,7 +32,5 @@ export const release: ReleaseConfig = { generateReleaseNotesForHead: async () => { exec('yarn -s gulp changelog', {cwd: join(__dirname, '../')}); }, - // The `comp: *` labels will be automatically added by PullApprove and the targeting label will - // be added by the release tooling, only `action: merge` must be manually included to the list. releasePrLabels: ['comp: build & ci', 'action: merge', 'PullApprove: disable'], }; diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index 80451d2834..eb699a79bb 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -5676,6 +5676,10 @@ class ReleaseAction { const { fork, branchName } = yield this._pushHeadToFork(proposedForkBranchName, true); const { data } = yield this.git.github.pulls.create(Object.assign(Object.assign({}, this.git.remoteParams), { head: `${fork.owner}:${branchName}`, base: targetBranch, body, title })); + // Add labels to the newly created PR if provided in the configuration. + if (this.config.releasePrLabels !== undefined) { + yield this.git.github.issues.addLabels(Object.assign(Object.assign({}, this.git.remoteParams), { issue_number: data.number, labels: this.config.releasePrLabels })); + } info(green(` ✓ Created pull request #${data.number} in ${repoSlug}.`)); return { id: data.number, diff --git a/dev-infra/release/config/index.ts b/dev-infra/release/config/index.ts index da1f759116..e8fb95909a 100644 --- a/dev-infra/release/config/index.ts +++ b/dev-infra/release/config/index.ts @@ -34,6 +34,8 @@ export interface ReleaseConfig { */ // TODO: Remove this in favor of a canonical changelog format across the Angular organization. extractReleaseNotesPattern?: (version: semver.SemVer) => RegExp; + /** The list of github labels to add to the release PRs. */ + releasePrLabels?: string[]; } /** Configuration for releases in the dev-infra configuration. */ diff --git a/dev-infra/release/publish/actions.ts b/dev-infra/release/publish/actions.ts index 3b22e81feb..fd55d6543b 100644 --- a/dev-infra/release/publish/actions.ts +++ b/dev-infra/release/publish/actions.ts @@ -282,6 +282,15 @@ export abstract class ReleaseAction { title, }); + // Add labels to the newly created PR if provided in the configuration. + if (this.config.releasePrLabels !== undefined) { + await this.git.github.issues.addLabels({ + ...this.git.remoteParams, + issue_number: data.number, + labels: this.config.releasePrLabels, + }); + } + info(green(` ✓ Created pull request #${data.number} in ${repoSlug}.`)); return { id: data.number,