Skip to content

Commit

Permalink
fix: update release scripts for react devtools (#31069)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hoxyq authored Sep 26, 2024
1 parent b90e440 commit b091ef7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
32 changes: 12 additions & 20 deletions scripts/devtools/build-and-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ async function main() {
});

const archivePath = await archiveGitRevision();
const buildID = await downloadLatestReactBuild();
const currentCommitHash = await downloadLatestReactBuild();

await buildAndTestInlinePackage();
await buildAndTestStandalonePackage();
await buildAndTestExtensions();

saveBuildMetadata({archivePath, buildID});
saveBuildMetadata({archivePath, currentCommitHash});

printFinalInstructions();
}
Expand Down Expand Up @@ -197,12 +197,17 @@ async function downloadLatestReactBuild() {

console.log('');

const currentCommitHash = (await exec('git rev-parse HEAD')).stdout.trim();
if (!currentCommitHash) {
throw new Error('Failed to get current commit hash');
}

const {commit} = await inquirer.prompt([
{
type: 'input',
name: 'commit',
message: 'Which React version (commit) should be used?',
default: 'main',
default: currentCommitHash,
},
]);
console.log('');
Expand All @@ -215,24 +220,11 @@ async function downloadLatestReactBuild() {
`"${downloadScriptPath}" --commit=${commit}`
);

const output = await logger(
downloadPromise,
'Downloading React artifacts from CI.',
{estimate: 15000}
);

const match = output.match('--build=([0-9]+)');
if (match.length === 0) {
console.error(chalk.red(`No build ID found in "${output}"`));
process.exit(1);
}

const buildID = match[1];

console.log('');
console.log(`Downloaded artifacts for CI build ${chalk.bold(buildID)}.`);
await logger(downloadPromise, 'Downloading React artifacts from CI.', {
estimate: 15000,
});

return buildID;
return currentCommitHash;
}

function printFinalInstructions() {
Expand Down
8 changes: 4 additions & 4 deletions scripts/devtools/publish-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ async function main() {
console.log(chalk.bold.green(' ' + pathToPrint));
});

const {archivePath, buildID} = readSavedBuildMetadata();
const {archivePath, currentCommitHash} = readSavedBuildMetadata();

await checkNPMPermissions();

await publishToNPM();

await printFinalInstructions(buildID, archivePath);
await printFinalInstructions(currentCommitHash, archivePath);
}

async function printFinalInstructions(buildID, archivePath) {
async function printFinalInstructions(currentCommitHash, archivePath) {
console.log('');
console.log(
'You are now ready to publish the extension to Chrome, Edge, and Firefox:'
Expand All @@ -50,7 +50,7 @@ async function printFinalInstructions(buildID, archivePath) {
);
console.log('');
console.log('When publishing to Firefox, remember the following:');
console.log(` Build id: ${chalk.bold(buildID)}`);
console.log(` Commit Hash: ${chalk.bold(currentCommitHash)}`);
console.log(` Git archive: ${chalk.bold(archivePath)}`);
console.log('');
console.log('Also consider syncing this release to Facebook:');
Expand Down
8 changes: 4 additions & 4 deletions scripts/devtools/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ function readSavedBuildMetadata() {
process.exit(1);
}

const {archivePath, buildID} = readJsonSync(path);
const {archivePath, currentCommitHash} = readJsonSync(path);

return {archivePath, buildID};
return {archivePath, currentCommitHash};
}

function saveBuildMetadata({archivePath, buildID}) {
function saveBuildMetadata({archivePath, currentCommitHash}) {
const path = join(BUILD_METADATA_TEMP_DIRECTORY, 'metadata');

if (!existsSync(BUILD_METADATA_TEMP_DIRECTORY)) {
mkdirSync(BUILD_METADATA_TEMP_DIRECTORY);
}

writeJsonSync(path, {archivePath, buildID}, {spaces: 2});
writeJsonSync(path, {archivePath, currentCommitHash}, {spaces: 2});
}

module.exports = {
Expand Down

0 comments on commit b091ef7

Please sign in to comment.