From ec9e97179ee789feb86d13830bc3062030c23152 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 23 Sep 2021 19:27:43 -0700 Subject: [PATCH] OSS: bump-oss-version -- update Podfile.lock later in the flow Summary: There was some hardcoded validation logic to verify package.json and gradle.properties update. Running `pod install` before that failed this validation on release branch, so let's move the pod update a bit later in the flow. This also restrict the version number change check to the specific files for better reliability Changelog: [Internal] Reviewed By: sota000 Differential Revision: D31160139 fbshipit-source-id: d32470d7dfc48c2efab1d2767f3892b33e0b77dd --- scripts/bump-oss-version.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index e565236fa09..055daf4777b 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -32,8 +32,6 @@ let argv = yargs }).argv; const nightlyBuild = argv.nightly; -// Nightly builds don't need an update as main will already be up-to-date. -const updatePodfileLock = !nightlyBuild; let version, branch; if (nightlyBuild) { @@ -154,33 +152,38 @@ if ( // Change react-native version in the template's package.json exec(`node scripts/set-rn-template-version.js ${version}`); -if (updatePodfileLock) { - echo('Updating RNTester Podfile.lock...') - if (exec('source scripts/update_podfile_lock.sh && update_pods').code) { - echo('Failed to update RNTester Podfile.lock.'); - echo('Fix the issue, revert and try again.'); - exit(1); - } -} - // Verify that files changed, we just do a git diff and check how many times version is added across files +const filesToValidate = [ + 'package.json', + 'ReactAndroid/gradle.properties', + 'template/package.json', +]; let numberOfChangedLinesWithNewVersion = exec( - `git diff -U0 | grep '^[+]' | grep -c ${version} `, + `git diff -U0 ${filesToValidate.join(' ')}| grep '^[+]' | grep -c ${version} `, {silent: true}, ).stdout.trim(); // Release builds should commit the version bumps, and create tags. // Nightly builds do not need to do that. if (!nightlyBuild) { - if (+numberOfChangedLinesWithNewVersion !== 3) { + if (+numberOfChangedLinesWithNewVersion !== filesToValidate.length) { echo( - 'Failed to update all the files. package.json and gradle.properties must have versions in them', + `Failed to update all the files: [${filesToValidate.join(', ')}] must have versions in them`, ); echo('Fix the issue, revert and try again'); exec('git diff'); exit(1); } + // Update Podfile.lock only on release builds, not nightly. + // Nightly builds don't need it as the main branch will already be up-to-date. + echo('Updating RNTester Podfile.lock...'); + if (exec('source scripts/update_podfile_lock.sh && update_pods').code) { + echo('Failed to update RNTester Podfile.lock.'); + echo('Fix the issue, revert and try again.'); + exit(1); + } + // Make commit [0.21.0-rc] Bump version numbers if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) { echo('failed to commit');