From 99673187ef17ed3ed2281cc1e65bc18636a6449a Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 23 Sep 2021 08:25:47 -0700 Subject: [PATCH] OSS: update Podfile.lock automatically when bumping release version Summary: To ensure consistency of RNTester Podfile.lock: * introduce a script to run `pod install` on the current commit * have the script check the exact CocoaPods version to use for consistency * have version bump script run this automatically to keep it up-to-date with the version change To validate, have this change in `0.66-stable` branch, then try: ``` ./scripts/bump-oss-version.js 0.66.0-rc.5 ``` This automatically ran `pod install` which produced the Podfile.lock update. Changelog: [Internal] Reviewed By: TheSavior Differential Revision: D31132867 fbshipit-source-id: 1c82653ca0cfc5471ed2c5091c09648a7acbab90 --- scripts/bump-oss-version.js | 11 +++++++++ scripts/update_podfile_lock.sh | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 scripts/update_podfile_lock.sh diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index ab582e3666ddb2..e565236fa090a7 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -32,6 +32,8 @@ 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) { @@ -152,6 +154,15 @@ 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 let numberOfChangedLinesWithNewVersion = exec( `git diff -U0 | grep '^[+]' | grep -c ${version} `, diff --git a/scripts/update_podfile_lock.sh b/scripts/update_podfile_lock.sh new file mode 100755 index 00000000000000..d1860c2f168f2b --- /dev/null +++ b/scripts/update_podfile_lock.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# This script updates RNTester Podfile.lock after verifying the CocoaPods environment. +# Usage: +# source scripts/update_podfile_lock && update_pods + +THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +RNTESTER_DIR="$THIS_DIR/../packages/rn-tester" + +# Note: Keep in sync with FB internal. +REQUIRED_COCOAPODS_VERSION="1.10.1" + +validate_env () { + # Check that CocoaPods is working. + if [ -z "$(command -v pod)" ]; then + echo "You need to install CocoaPods." + echo "See https://guides.cocoapods.org/using/getting-started.html#getting-started for instructions." + exit 1 + fi + + COCOAPODS_VERSION=$(pod --version) + if [[ "$COCOAPODS_VERSION" != "$REQUIRED_COCOAPODS_VERSION" ]]; + then + echo "You must have CocoaPods $REQUIRED_COCOAPODS_VERSION installed; you have $COCOAPODS_VERSION." + echo "Installing via gem is recommended:" + echo " sudo gem install cocoapods -v $REQUIRED_COCOAPODS_VERSION" + exit 1 + fi +} + +update_pods () { + validate_env + + cd "$RNTESTER_DIR" || exit + pod install + cd "$THIS_DIR" || exit +}