Skip to content

Commit

Permalink
feat: add labels to release PR
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed Feb 20, 2023
1 parent 85ef2b0 commit 7daf234
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions messages/cli.release.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"resolutions": "bump the versions of packages listed in the resolutions section",
"pinnedDeps": "bump the versions of the packages listed in the pinnedDependencies section",
"jit": "bump the versions of the packages listed in the jitPlugins (just-in-time) section",
"label": "add one or more labels to the Github PR",
"only": "only bump the version of the packages passed in, uses latest if version is not provided",
"patch": "bump the release as a patch of an existing version, not a new minor version",
"prerelease": "name of the prerelease to create, examples: dev, alpha",
Expand Down
16 changes: 15 additions & 1 deletion src/commands/cli/release/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export default class build extends SfCommand<void> {
default: true,
allowNo: true,
}),
label: Flags.string({
summary: messages.getMessage('flags.label'),
multiple: true,
}),
patch: Flags.boolean({
summary: messages.getMessage('flags.patch'),
exclusive: ['prerelease'],
Expand Down Expand Up @@ -201,14 +205,24 @@ export default class build extends SfCommand<void> {
const prereleaseDetails =
'\n**IMPORTANT:**\nPrereleases work differently than regular releases. Github Actions watches for branches prefixed with `prerelease/`. As long as the `package.json` contains a valid "prerelease tag" (1.2.3-dev.0), a new prerelease will be created for EVERY COMMIT pushed to that branch. If you would like to merge this PR into `main`, simply push one more commit to this branch that sets the version in the `package.json` to the version you\'d like to release.';

await octokit.request(`POST /repos/${repoOwner}/${repoName}/pulls`, {
const pr = await octokit.request('POST /repos/{owner}/{repo}/pulls', {
owner: repoOwner,
repo: repoName,
head: branchName,
base: 'main',
title: `Release PR for ${nextVersion}`,
body: `Building ${nextVersion} [skip-validate-pr]${flags.prerelease ? prereleaseDetails : ''}`,
});

if (flags.label) {
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: repoOwner,
repo: repoName,
// eslint-disable-next-line camelcase
issue_number: pr.data.number,
labels: flags.label,
});
}
}
}

Expand Down

0 comments on commit 7daf234

Please sign in to comment.