Skip to content
Open
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
124 changes: 28 additions & 96 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,119 +133,51 @@ export default class ReleasePreparation extends Session {
return true;
}

async prepareSecurity() {
const {
cli,
newVersion,
versionComponents,
releaseBranch,
filterLabels
} = this;

// Create new proposal branch.
cli.startSpinner(`Switching to proposal branch for ${newVersion}`);
const proposalBranch = await this.createProposalBranch(releaseBranch);
cli.stopSpinner(`Switched to proposal branch for ${newVersion}`);

const success = await this.cherryPickSecurityPRs(filterLabels);
if (!success) {
cli.error('Aborting security release preparation. ' +
'Remember to exclude the proposal branch.' +
'git branch -D ' + proposalBranch);
return;
}
// Update version and release info in src/node_version.h.
cli.startSpinner(`Updating 'src/node_version.h' for ${newVersion}`);
await this.updateNodeVersion();
cli.stopSpinner(`Updated 'src/node_version.h' for ${newVersion}`);

// Update any REPLACEME tags in the docs.
cli.startSpinner('Updating REPLACEME items in docs');
await this.updateREPLACEMEs();
cli.stopSpinner('Updated REPLACEME items in docs');

// Fetch date to use in release commit & changelogs.
const todayDate = new Date().toISOString().split('T')[0];
this.date = await cli.prompt('Enter release date in YYYY-MM-DD format:',
{ questionType: 'input', defaultAnswer: todayDate });

cli.startSpinner('Updating CHANGELOG.md');
await this.updateMainChangelog();
cli.stopSpinner('Updated CHANGELOG.md');

cli.startSpinner(`Updating CHANGELOG_V${versionComponents.major}.md`);
await this.updateMajorChangelog();
cli.stopSpinner(`Updated CHANGELOG_V${versionComponents.major}.md`);

// Create release commit.
const shouldCreateReleaseCommit = await cli.prompt(
'Create release commit?');
if (!shouldCreateReleaseCommit) {
cli.warn(`Aborting \`git node release\` for version ${newVersion}`);
return;
}

// Proceed with release only after the releaser has amended
// it to their liking.
const createDefaultCommit = await this.createReleaseCommit();
if (!createDefaultCommit) {
const lastCommitSha = runSync('git', ['rev-parse', '--short', 'HEAD']);
cli.warn(`Please manually edit commit ${lastCommitSha} by running ` +
'`git commit --amend` before proceeding.');
}

cli.separator();
cli.ok(`Release preparation for ${newVersion} complete.\n`);
cli.info(
'To finish the release proposal, run: \n' +
` $ git push -u ${this.upstream} v${newVersion}-proposal\n` +
'Finally, proceed to Jenkins and begin the following CI jobs:\n' +
' * https://ci.nodejs.org/job/node-test-pull-request/\n' +
' * https://ci.nodejs.org/job/citgm-smoker/');
cli.info(
'If this release has deps/v8 changes, you\'ll also need to run:\n' +
' * https://ci.nodejs.org/job/node-test-commit-v8-linux/'
);
}

async prepare() {
const { cli, newVersion, versionComponents, isSecurityRelease } = this;

if (isSecurityRelease) {
this.config.owner = 'nodejs-private';
this.config.repo = 'node-private';
return this.prepareSecurity();
}

const runBranchDiff = await cli.prompt(
'Do you want to check if any additional commits could be backported ' +
'(recommended except for Maintenance releases)?',
{ defaultAnswer: this.runBranchDiff });
if (runBranchDiff) {
// TODO: UPDATE re-use
// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = await this.getBranchDiff({
onlyNotableChanges: false,
comparisonBranch: newVersion
});

const diff = raw.split('*');
cli.stopSpinner('Got branch diff');

const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const proceed = await cli.prompt(
if (isSecurityRelease) {
const success = await this.cherryPickSecurityPRs(this.filterLabels);
if (!success) {
cli.error('Aborting security release preparation.');
return;
}
} else {
// TODO: UPDATE re-use
// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = await this.getBranchDiff({
onlyNotableChanges: false,
comparisonBranch: newVersion
});

const diff = raw.split('*');
cli.stopSpinner('Got branch diff');

const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const proceed = await cli.prompt(
`There are ${outstandingCommits} commits that may be ` +
`backported to ${this.stagingBranch} - do you still want to proceed?`,
{ defaultAnswer: false });

if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
}
}
}
}
Expand Down
Loading