Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update release scripts for react devtools #31069

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading