Repository: facebook/react
Pull request: Updated release scripts to work around GitHub / Circle CI integration problems

The GitHub/CircleCI issue is blocking the DevTools release 😦 

This updates the release scripts so they can accept a `--build` parameter in addition to a `--commit` parameter.

So before we would run either:
```sh
scripts/release/download-experimental-build.js # defaults to latest in master
```

We can still do that now, explicitly:
```sh
scripts/release/download-experimental-build.js --commit=master
```

But we can also do:
```sh
scripts/release/download-experimental-build.js --build=<number>
```

Here's it working even with a revision that GitHub/CircleCI are out of sync on:
![Script demo](https://user-images.githubusercontent.com/29597/117176657-18f3c900-ad9e-11eb-94e8-64e8fdbdc49e.gif)


Changed files:
filename: scripts/release/download-experimental-build-commands/print-summary.js
patch: @@ -5,23 +5,20 @@
 const clear = require('clear');
 const {join, relative} = require('path');
 const theme = require('../theme');
-const {getCommitFromCurrentBuild} = require('../utils');
 
-module.exports = async () => {
+module.exports = async ({build}) => {
   const commandPath = relative(
     process.env.PWD,
     join(__dirname, '../download-experimental-build.js')
   );
 
   clear();
 
-  const commit = await getCommitFromCurrentBuild();
-
   const message = theme`
     {caution An experimental build has been downloaded!}
 
     You can download this build again by running:
-    {path   ${commandPath}} --commit={commit ${commit}}
+    {path   ${commandPath}} --build={build ${build}}
   `;
 
   console.log(message.replace(/\n +/g, '\n').trim());

filename: scripts/release/download-experimental-build.js
patch: @@ -17,10 +17,6 @@ const run = async () => {
   try {
     addDefaultParamValue('-r', '--releaseChannel', 'experimental');
 
-    // Default to the latest commit in master.
-    // If this is a reproducible build (e.g. Firefox tester) a --commit will be specified.
-    addDefaultParamValue(null, '--commit', 'master');
-
     const params = await parseParams();
     params.cwd = join(__dirname, '..', '..');
     params.packages = await getPublicPackages(true);

filename: scripts/release/shared-commands/download-build-artifacts.js
patch: @@ -51,8 +51,14 @@ const run = async ({build, cwd, releaseChannel}) => {
 };
 
 module.exports = async ({build, commit, cwd, releaseChannel}) => {
+  let buildLabel;
+  if (commit !== null) {
+    buildLabel = theme`commit {commit ${commit}} (build {build ${build}})`;
+  } else {
+    buildLabel = theme`build {build ${build}}`;
+  }
   return logPromise(
     run({build, cwd, releaseChannel}),
-    theme`Downloading artifacts from Circle CI for commit {commit ${commit}} (build {build ${build}})`
+    theme`Downloading artifacts from Circle CI for ${buildLabel}`
   );
 };

filename: scripts/release/shared-commands/parse-params.js
patch: @@ -3,10 +3,18 @@
 'use strict';
 
 const commandLineArgs = require('command-line-args');
-const getBuildIdForCommit = require('../get-build-id-for-commit');
+const getBuildIdForCommit = require('./get-build-id-for-commit');
 const theme = require('../theme');
+const {logPromise} = require('../utils');
 
 const paramDefinitions = [
+  {
+    name: 'build',
+    type: String,
+    description:
+      'CI build ID corresponding to the "process_artifacts_combined" task.',
+    defaultValue: null,
+  },
   {
     name: 'commit',
     type: String,
@@ -39,13 +47,20 @@ module.exports = async () => {
     process.exit(1);
   }
 
-  if (params.commit === null) {
-    console.error(theme.error`No --commit param specified.`);
+  if (params.build === null && params.commit === null) {
+    console.error(
+      theme.error`Either a --commit or --build param must be specified.`
+    );
     process.exit(1);
   }
 
   try {
-    params.build = await getBuildIdForCommit(params.commit);
+    if (params.build === null) {
+      params.build = await logPromise(
+        getBuildIdForCommit(params.commit),
+        theme`Getting build ID for commit "${params.commit}"`
+      );
+    }
   } catch (error) {
     console.error(theme.error(error));
     process.exit(1);