From 3400b6704cf1aaf76661503c5ff12f7f7db4478d Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 25 Nov 2020 09:28:10 +0100 Subject: [PATCH 1/4] Update publish-npm.js --- scripts/publish-npm.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 6107a9efd2a1a6..b2f8dd805e1c60 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -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`); + 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.'); + buildAndroid(false); + } else { + echo('Artifacts are corrupted. Exiting.'); + exit(1); + } } +buildAndroid(true); + // undo uncommenting javadoc setting exec('git checkout ReactAndroid/gradle.properties'); From 71f6d6ab572855c7dab0e860824ee4f7f940d4be Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 25 Nov 2020 11:31:03 +0100 Subject: [PATCH 2/4] Update scripts/publish-npm.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eloy Durán --- scripts/publish-npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index b2f8dd805e1c60..f1658d79a235b6 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -148,7 +148,7 @@ const buildAndroid = (rebuildOnError) => { // -------- 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.'); + echo(`${aarLocation} is missing contents. Rebuilding with Gradle again in an effort to try to fix it.`); buildAndroid(false); } else { echo('Artifacts are corrupted. Exiting.'); From 4e8788818a82bdd337c5448cb5fb9cab02ddb761 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 25 Nov 2020 11:31:13 +0100 Subject: [PATCH 3/4] Update scripts/publish-npm.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eloy Durán --- scripts/publish-npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index f1658d79a235b6..8842c3fe6b3e41 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -151,7 +151,7 @@ const buildAndroid = (rebuildOnError) => { echo(`${aarLocation} is missing contents. Rebuilding with Gradle again in an effort to try to fix it.`); buildAndroid(false); } else { - echo('Artifacts are corrupted. Exiting.'); + echo(`${aarLocation} is missing contents. Rebuilding did not fix the issue.`); exit(1); } } From 0a2c95d590322b1d4508be433d7b52415b0638d5 Mon Sep 17 00:00:00 2001 From: grabbou Date: Wed, 25 Nov 2020 11:34:12 +0100 Subject: [PATCH 4/4] chore: use -l flag --- scripts/publish-npm.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 8842c3fe6b3e41..dc611c803f202b 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -134,13 +134,9 @@ const buildAndroid = (rebuildOnError) => { } 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`); + const {stdout: aarContent} = exec(`unzip -l ${aarLocation} | grep libfbjni.so`); if ((aarContent.match(/libfbjni.so/g) || []).length === 4) { echo(`Artifacts validated, continuing.`); return; @@ -183,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}` : '';