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.
Ruslan Lesiutin committed
Sep 26, 2024 at 15:42 UTC
b091ef7e0be078de64721e72b8dc8d7bc33dad29
3 files changed
+20
-28
scripts/devtools/build-and-test.js
+12
-20
@@ -50,13 +50,13 @@ async function main() {
50
});
51
52
const archivePath = await archiveGitRevision();
53
- const buildID = await downloadLatestReactBuild();
53
+ const currentCommitHash = await downloadLatestReactBuild();
54
55
await buildAndTestInlinePackage();
56
await buildAndTestStandalonePackage();
57
await buildAndTestExtensions();
58
59
- saveBuildMetadata({archivePath, buildID});
59
+ saveBuildMetadata({archivePath, currentCommitHash});
60
61
printFinalInstructions();
62
}
@@ -197,12 +197,17 @@ async function downloadLatestReactBuild() {
197
198
console.log('');
199
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
+
205
const {commit} = await inquirer.prompt([
206
{
207
type: 'input',
208
name: 'commit',
209
message: 'Which React version (commit) should be used?',
205
- default: 'main',
210
+ default: currentCommitHash,
211
},
212
]);
213
console.log('');
@@ -215,24 +220,11 @@ async function downloadLatestReactBuild() {
220
`"${downloadScriptPath}" --commit=${commit}`
221
);
222
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
+ });
226
235
- return buildID;
227
+ return currentCommitHash;
228
}
229
230
function printFinalInstructions() {
scripts/devtools/publish-release.js
+4
-4
@@ -29,16 +29,16 @@ async function main() {
29
console.log(chalk.bold.green(' ' + pathToPrint));
30
});
31
32
- const {archivePath, buildID} = readSavedBuildMetadata();
32
+ const {archivePath, currentCommitHash} = readSavedBuildMetadata();
33
34
await checkNPMPermissions();
35
36
await publishToNPM();
37
38
- await printFinalInstructions(buildID, archivePath);
38
+ await printFinalInstructions(currentCommitHash, archivePath);
39
}
40
41
-async function printFinalInstructions(buildID, archivePath) {
41
+async function printFinalInstructions(currentCommitHash, archivePath) {
42
console.log('');
43
console.log(
44
'You are now ready to publish the extension to Chrome, Edge, and Firefox:'
@@ -50,7 +50,7 @@ async function printFinalInstructions(buildID, archivePath) {
50
);
51
console.log('');
52
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)}`);
54
console.log(` Git archive: ${chalk.bold(archivePath)}`);
55
console.log('');
56
console.log('Also consider syncing this release to Facebook:');
scripts/devtools/utils.js
+4
-4
@@ -101,19 +101,19 @@ function readSavedBuildMetadata() {
101
process.exit(1);
102
}
103
104
- const {archivePath, buildID} = readJsonSync(path);
104
+ const {archivePath, currentCommitHash} = readJsonSync(path);
105
106
- return {archivePath, buildID};
106
+ return {archivePath, currentCommitHash};
107
}
108
109
-function saveBuildMetadata({archivePath, buildID}) {
109
+function saveBuildMetadata({archivePath, currentCommitHash}) {
110
const path = join(BUILD_METADATA_TEMP_DIRECTORY, 'metadata');
111
112
if (!existsSync(BUILD_METADATA_TEMP_DIRECTORY)) {
113
mkdirSync(BUILD_METADATA_TEMP_DIRECTORY);
114
}
115
116
- writeJsonSync(path, {archivePath, buildID}, {spaces: 2});
116
+ writeJsonSync(path, {archivePath, currentCommitHash}, {spaces: 2});
117
}
118
119
module.exports = {