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: android artifacts in a release package #30470

Closed
Closed
Changes from 1 commit
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
34 changes: 30 additions & 4 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,38 @@ if (nightlyBuild) {
releaseVersion = tagsWithVersion[tagsWithVersion.length - 1].slice(1);
}

// -------- Generating Android Artifacts with JavaDoc
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
const buildAndroid = (rebuildOnError) => {
// -------- Generating Android Artifacts with JavaDoc
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts.');
exit(1);
}

const aarLocation = `android/com/facebook/react/react-native/${releaseVersion}/react-native-${releaseVersion}.aar`;
const tmpLocation = `/tmp/react-native-${releaseVersion}`;

// -------- Remove unzipped Android artifact (if any)
exec(`rm -rf ${tmpLocation}`);

// -------- Check if Android artifact contains all the files
const {stdout: aarContent} = exec(`unzip ${aarLocation} -d ${tmpLocation} | grep libfbjni.so`);
grabbou marked this conversation as resolved.
Show resolved Hide resolved
if ((aarContent.match(/libfbjni.so/g) || []).length === 4) {
echo(`Artifacts validated, continuing.`);
return;
}

// -------- Temporary fix for broken Android artifact is to build with Gradle once again
if (rebuildOnError) {
echo('Artifacts are corrupted. Rebuilding with Gradle once again to fix it.');
grabbou marked this conversation as resolved.
Show resolved Hide resolved
buildAndroid(false);
} else {
echo('Artifacts are corrupted. Exiting.');
grabbou marked this conversation as resolved.
Show resolved Hide resolved
exit(1);
}
}

buildAndroid(true);

// undo uncommenting javadoc setting
exec('git checkout ReactAndroid/gradle.properties');

Expand Down