Skip to content

Commit

Permalink
OSS: bump-oss-version -- update Podfile.lock later in the flow
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fkgozali committed Sep 24, 2021
1 parent ef280d6 commit a6a983d
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions scripts/bump-oss-version.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit a6a983d

Please sign in to comment.