Skip to content

Commit b091ef7

Browse files
authored
fix: update release scripts for react devtools (#31069)
This has been broken since the migration to GitHub actions. Previously, we've been using `buildId` as an identifier from CircleCI. I've decided to use a commit hash as an identifier, because I don't know if there is a better option, and `scripts/release/download_build_artifacts.js` allows us to download them for a specific commit.
1 parent b90e440 commit b091ef7

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

scripts/devtools/build-and-test.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ async function main() {
5050
});
5151

5252
const archivePath = await archiveGitRevision();
53-
const buildID = await downloadLatestReactBuild();
53+
const currentCommitHash = await downloadLatestReactBuild();
5454

5555
await buildAndTestInlinePackage();
5656
await buildAndTestStandalonePackage();
5757
await buildAndTestExtensions();
5858

59-
saveBuildMetadata({archivePath, buildID});
59+
saveBuildMetadata({archivePath, currentCommitHash});
6060

6161
printFinalInstructions();
6262
}
@@ -197,12 +197,17 @@ async function downloadLatestReactBuild() {
197197

198198
console.log('');
199199

200+
const currentCommitHash = (await exec('git rev-parse HEAD')).stdout.trim();
201+
if (!currentCommitHash) {
202+
throw new Error('Failed to get current commit hash');
203+
}
204+
200205
const {commit} = await inquirer.prompt([
201206
{
202207
type: 'input',
203208
name: 'commit',
204209
message: 'Which React version (commit) should be used?',
205-
default: 'main',
210+
default: currentCommitHash,
206211
},
207212
]);
208213
console.log('');
@@ -215,24 +220,11 @@ async function downloadLatestReactBuild() {
215220
`"${downloadScriptPath}" --commit=${commit}`
216221
);
217222

218-
const output = await logger(
219-
downloadPromise,
220-
'Downloading React artifacts from CI.',
221-
{estimate: 15000}
222-
);
223-
224-
const match = output.match('--build=([0-9]+)');
225-
if (match.length === 0) {
226-
console.error(chalk.red(`No build ID found in "${output}"`));
227-
process.exit(1);
228-
}
229-
230-
const buildID = match[1];
231-
232-
console.log('');
233-
console.log(`Downloaded artifacts for CI build ${chalk.bold(buildID)}.`);
223+
await logger(downloadPromise, 'Downloading React artifacts from CI.', {
224+
estimate: 15000,
225+
});
234226

235-
return buildID;
227+
return currentCommitHash;
236228
}
237229

238230
function printFinalInstructions() {

scripts/devtools/publish-release.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ async function main() {
2929
console.log(chalk.bold.green(' ' + pathToPrint));
3030
});
3131

32-
const {archivePath, buildID} = readSavedBuildMetadata();
32+
const {archivePath, currentCommitHash} = readSavedBuildMetadata();
3333

3434
await checkNPMPermissions();
3535

3636
await publishToNPM();
3737

38-
await printFinalInstructions(buildID, archivePath);
38+
await printFinalInstructions(currentCommitHash, archivePath);
3939
}
4040

41-
async function printFinalInstructions(buildID, archivePath) {
41+
async function printFinalInstructions(currentCommitHash, archivePath) {
4242
console.log('');
4343
console.log(
4444
'You are now ready to publish the extension to Chrome, Edge, and Firefox:'
@@ -50,7 +50,7 @@ async function printFinalInstructions(buildID, archivePath) {
5050
);
5151
console.log('');
5252
console.log('When publishing to Firefox, remember the following:');
53-
console.log(` Build id: ${chalk.bold(buildID)}`);
53+
console.log(` Commit Hash: ${chalk.bold(currentCommitHash)}`);
5454
console.log(` Git archive: ${chalk.bold(archivePath)}`);
5555
console.log('');
5656
console.log('Also consider syncing this release to Facebook:');

scripts/devtools/utils.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ function readSavedBuildMetadata() {
101101
process.exit(1);
102102
}
103103

104-
const {archivePath, buildID} = readJsonSync(path);
104+
const {archivePath, currentCommitHash} = readJsonSync(path);
105105

106-
return {archivePath, buildID};
106+
return {archivePath, currentCommitHash};
107107
}
108108

109-
function saveBuildMetadata({archivePath, buildID}) {
109+
function saveBuildMetadata({archivePath, currentCommitHash}) {
110110
const path = join(BUILD_METADATA_TEMP_DIRECTORY, 'metadata');
111111

112112
if (!existsSync(BUILD_METADATA_TEMP_DIRECTORY)) {
113113
mkdirSync(BUILD_METADATA_TEMP_DIRECTORY);
114114
}
115115

116-
writeJsonSync(path, {archivePath, buildID}, {spaces: 2});
116+
writeJsonSync(path, {archivePath, currentCommitHash}, {spaces: 2});
117117
}
118118

119119
module.exports = {

0 commit comments

Comments
 (0)