@samitouri / QOS-React / commits / 8a0285fb43

Release script follow-up (#11482)

* Add a timeout before querying npm right after publish * Conditionally log some post publish steps * Print ready-to-paste 'yarn add' instructions for CRA prerelease testing

Brian Vaughn committed Nov 8, 2017 at 19:59 UTC 8a0285fb43a3109aa7cd7b31ad91b007910fc5f8
2 files changed +64 -23
scripts/release/publish-commands/print-post-publish-summary.js
+60 -23
@@ -3,39 +3,76 @@
3 'use strict';
4
5 const chalk = require('chalk');
6 +const semver = require('semver');
7 const {getUnexecutedCommands} = require('../utils');
8
8 -module.exports = ({version}) => {
9 - console.log(
10 - chalk`
11 - {green.bold Publish successful!}
12 - ${getUnexecutedCommands()}
13 - Next there are a couple of manual steps:
9 +const printSteps = steps => {
10 + return steps
11 + .filter(Boolean) // Remove no-op steps
12 + .map((step, index) => `${index + 1}. ${step}`)
13 + .join('\n');
14 +};
15 +
16 +const printSections = sections => {
17 + return sections
18 + .map((section, index) => {
19 + const [title, ...steps] = section;
20
15 - {bold.underline Step 1: Create GitHub release}
21 + return chalk`
22 + {bold.underline Step ${index + 1}: ${title}}
23
17 - 1. Open new release page: {blue.bold https://github.com/facebook/react/releases/new}
18 - 2. Choose {bold ${version}} from the dropdown menu
19 - 3. Paste the new release notes from {yellow.bold CHANGELOG.md}
20 - 4. Attach all files in {yellow.bold build/dist/*.js} except {yellow.bold react-art.*} to the release.
21 - 5. Press {bold "Publish release"}!
24 + ${printSteps(steps)}
25 + `.replace(/\n +/g, '\n');
26 + })
27 + .join('');
28 +};
29 +
30 +module.exports = ({dry, version}) => {
31 + const isPrerelease = semver.prerelease(version);
32
23 - {bold.underline Step 2: Update the version on reactjs.org}
33 + const sections = [];
34
25 - 1. Git clone (or update) {blue.bold https://github.com/reactjs/reactjs.org}
26 - 2. Open the {bold.yellow src/site-constants.js} file
27 - 3. Update the {bold version} value to {bold ${version}}
28 - 4. Open a Pull Request to {bold master}
35 + // Certain follow-up steps are for stable releases only.
36 + if (!isPrerelease) {
37 + sections.push([
38 + 'Create GitHub release',
39 + chalk`Open new release page: {blue.bold https://github.com/facebook/react/releases/new}`,
40 + chalk`Choose {bold ${version}} from the dropdown menu`,
41 + chalk`Paste the new release notes from {yellow.bold CHANGELOG.md}`,
42 + chalk`Attach all files in {yellow.bold build/dist/*.js} except {yellow.bold react-art.*} to the release.`,
43 + chalk`Press {bold "Publish release"}!`,
44 + ]);
45
30 - {bold.underline Step 3: Test the new release}
46 + sections.push([
47 + 'Update the version on reactjs.org',
48 + chalk`Git clone (or update) {blue.bold https://github.com/reactjs/reactjs.org}`,
49 + chalk`Open the {bold.yellow src/site-constants.js} file`,
50 + chalk`Update the {bold version} value to {bold ${version}}`,
51 + chalk`Open a Pull Request to {bold master}`,
52 + ]);
53 + }
54
32 - 1. Install CRA: {bold npm i -g create-react-app}
33 - 2. Create a test application: {bold create-react-app myapp}
34 - 3. Run it: {bold cd myapp && npm start}
55 + sections.push([
56 + 'Test the new release',
57 + chalk`Install CRA: {bold npm i -g create-react-app}`,
58 + chalk`Create a test application: {bold create-react-app myapp && cd myapp}`,
59 + isPrerelease
60 + ? chalk`Install the pre-release versions: {bold yarn add react@next react-dom@next}`
61 + : null,
62 + chalk`Run the app: {bold yarn start}`,
63 + ]);
64
36 - {bold.underline Step 4: Notify the DOM team}
65 + sections.push([
66 + 'Notify the DOM team',
67 + chalk`Notify DOM team members: {bold @nhunzaker @jquense @aweary}`,
68 + ]);
69
38 - 1. Notify DOM team members: {bold @nhunzaker @jquense @aweary}
70 + console.log(
71 + chalk`
72 + {green.bold Publish successful!}
73 + ${getUnexecutedCommands()}
74 + Next there are a couple of manual steps:
75 + ${printSections(sections)}
76 `.replace(/\n +/g, '\n')
77 );
78 };
scripts/release/publish-commands/publish-to-npm.js
+4
@@ -30,6 +30,10 @@ const push = async ({cwd, dry, version}) => {
30 const packageVersion = packageJSON.version;
31
32 if (!dry) {
33 + // Wait a couple of seconds before querying NPM for status;
34 + // Anecdotally, querying too soon can result in a false negative.
35 + await new Promise(resolve => setTimeout(resolve, 5000));
36 +
37 const status = JSON.parse(
38 await execRead(`npm info ${project} dist-tags --json`)
39 );