Skip to content

Commit 4399cf0

Browse files
authored
feat(git-node): add support for promoting several releases at once (#935)
1 parent ce893fc commit 4399cf0

File tree

2 files changed

+155
-138
lines changed

2 files changed

+155
-138
lines changed

components/git/release.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import TeamInfo from '../../lib/team_info.js';
66
import Request from '../../lib/request.js';
77
import { runPromise } from '../../lib/run.js';
88

9-
export const command = 'release [prid|options]';
9+
export const command = 'release [prid..]';
1010
export const describe = 'Manage an in-progress release or start a new one.';
1111

1212
const PREPARE = 'prepare';
@@ -34,8 +34,13 @@ const releaseOptions = {
3434
describe: 'Promote new release of Node.js',
3535
type: 'boolean'
3636
},
37+
fetchFrom: {
38+
describe: 'Remote to fetch the release proposal(s) from, if different from the one where to' +
39+
'push the tags and commits.',
40+
type: 'string',
41+
},
3742
releaseDate: {
38-
describe: 'Default relase date when --prepare is used. It must be YYYY-MM-DD',
43+
describe: 'Default release date when --prepare is used. It must be YYYY-MM-DD',
3944
type: 'string'
4045
},
4146
run: {
@@ -112,11 +117,6 @@ function release(state, argv) {
112117
}
113118

114119
async function main(state, argv, cli, dir) {
115-
const prID = /^(?:https:\/\/github\.com\/nodejs(-private)?\/node\1\/pull\/)?(\d+)$/.exec(argv.prid);
116-
if (prID) {
117-
if (prID[1]) argv.security = true;
118-
argv.prid = Number(prID[2]);
119-
}
120120
if (state === PREPARE) {
121121
const release = new ReleasePreparation(argv, cli, dir);
122122

@@ -160,6 +160,24 @@ async function main(state, argv, cli, dir) {
160160
cli.stopSpinner(`${release.username} is a Releaser`);
161161
}
162162

163-
return release.promote();
163+
const releases = [];
164+
for (const pr of argv.prid) {
165+
const match = /^(?:https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/)?(\d+)(?:#.*)?$/.exec(pr);
166+
if (!match) throw new Error('Invalid PR ID or URL', { cause: pr });
167+
const [,owner, repo, prid] = match;
168+
169+
if (
170+
owner &&
171+
(owner !== release.owner || repo !== release.repo) &&
172+
!argv.fetchFrom
173+
) {
174+
console.warn('The configured owner/repo does not match the PR URL.');
175+
console.info('You should either pass `--fetch-from` flag or check your configuration');
176+
console.info(`E.g. [email protected]:${owner}/${repo}.git`);
177+
throw new Error('You need to tell what remote use to fetch security release proposal.');
178+
}
179+
releases.push(await release.preparePromotion({ owner, repo, prid: Number(prid) }));
180+
}
181+
return release.promote(releases);
164182
}
165183
}

0 commit comments

Comments
 (0)