Skip to content

Commit

Permalink
fix: android artifacts in publish-npm.js
Browse files Browse the repository at this point in the history
  • Loading branch information
grabbou committed Nov 25, 2020
1 parent 9f0f8a5 commit e2be26a
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,34 @@ 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`;

// -------- Check if Android artifact contains all the files
const {stdout: aarContent} = exec(`unzip -l ${aarLocation} | grep libfbjni.so`);
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(`${aarLocation} is missing contents. Rebuilding with Gradle again in an effort to try to fix it.`);
buildAndroid(false);
} else {
echo(`${aarLocation} is missing contents. Rebuilding did not fix the issue.`);
exit(1);
}
}

buildAndroid(true);

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

Expand All @@ -157,8 +179,8 @@ artifacts.forEach(name => {
const tagFlag = nightlyBuild
? '--tag nightly'
: releaseVersion.indexOf('-rc') === -1
? ''
: '--tag next';
? ''
: '--tag next';

// use otp from envvars if available
const otpFlag = otp ? `--otp ${otp}` : '';
Expand Down

0 comments on commit e2be26a

Please sign in to comment.