Skip to content

Update publish-npm.js #27

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
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