Skip to content

feat(git-node): add support for promoting several releases at once #935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions components/git/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TeamInfo from '../../lib/team_info.js';
import Request from '../../lib/request.js';
import { runPromise } from '../../lib/run.js';

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

const PREPARE = 'prepare';
Expand Down Expand Up @@ -34,8 +34,13 @@ const releaseOptions = {
describe: 'Promote new release of Node.js',
type: 'boolean'
},
fetchFrom: {
describe: 'Remote to fetch the release proposal(s) from, if different from the one where to' +
'push the tags and commits.',
type: 'string',
},
releaseDate: {
describe: 'Default relase date when --prepare is used. It must be YYYY-MM-DD',
describe: 'Default release date when --prepare is used. It must be YYYY-MM-DD',
type: 'string'
},
run: {
Expand Down Expand Up @@ -112,11 +117,6 @@ function release(state, argv) {
}

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

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

return release.promote();
const releases = [];
for (const pr of argv.prid) {
const match = /^(?:https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/)?(\d+)(?:#.*)?$/.exec(pr);
if (!match) throw new Error('Invalid PR ID or URL', { cause: pr });
const [,owner, repo, prid] = match;

if (
owner &&
(owner !== release.owner || repo !== release.repo) &&
!argv.fetchFrom
) {
console.warn('The configured owner/repo does not match the PR URL.');
console.info('You should either pass `--fetch-from` flag or check your configuration');
console.info(`E.g. [email protected]:${owner}/${repo}.git`);
throw new Error('You need to tell what remote use to fetch security release proposal.');
}
releases.push(await release.preparePromotion({ owner, repo, prid: Number(prid) }));
}
return release.promote(releases);
}
}
Loading
Loading