Skip to content

Automate fetching of the latest nightly #51504

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

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 24 additions & 1 deletion packages/react-native/scripts/ios-prebuild/hermes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ async function prepareHermesArtifactsAsync(
// Only check if the artifacts folder exists if we are not using a local tarball
if (!localPath) {
// Resolve the version from the environment variable or use the default version
const resolvedVersion = process.env.HERMES_VERSION ?? version;
let resolvedVersion = process.env.HERMES_VERSION ?? version;

if (resolvedVersion === 'nightly') {
hermesLog('Using latest nightly tarball');
const hermesVersion = await getNightlyVersionFromNPM();
resolvedVersion = hermesVersion;
}

// Check if the Hermes artifacts are already downloaded
if (
Expand Down Expand Up @@ -89,6 +95,23 @@ async function prepareHermesArtifactsAsync(
return artifactsPath;
}

async function getNightlyVersionFromNPM() /*: Promise<string> */ {
const npmResponse /*: Response */ = await fetch(
'https://registry.npmjs.org/react-native/nightly',
);

if (!npmResponse.ok) {
throw new Error(
`Couldn't get an answer from NPM: ${npmResponse.status} ${npmResponse.statusText}`,
);
}

const json = await npmResponse.json();
const latestNightly = json.version;
hermesLog(`Using version ${latestNightly}`);
return latestNightly;
}

/*::
type HermesEngineSourceType =
| 'local_prebuilt_tarball'
Expand Down
Loading