Skip to content

Commit d3c7e20

Browse files
fkgozalifacebook-github-bot
authored andcommitted
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
1 parent 1a1c3a6 commit d3c7e20

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

scripts/bump-oss-version.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ let argv = yargs
3232
}).argv;
3333

3434
const nightlyBuild = argv.nightly;
35+
// Nightly builds don't need an update as main will already be up-to-date.
36+
const updatePodfileLock = !nightlyBuild;
3537

3638
let version, branch;
3739
if (nightlyBuild) {
@@ -152,6 +154,15 @@ if (
152154
// Change react-native version in the template's package.json
153155
exec(`node scripts/set-rn-template-version.js ${version}`);
154156

157+
if (updatePodfileLock) {
158+
echo('Updating RNTester Podfile.lock...')
159+
if (exec('source scripts/update_podfile_lock.sh && update_pods').code) {
160+
echo('Failed to update RNTester Podfile.lock.');
161+
echo('Fix the issue, revert and try again.');
162+
exit(1);
163+
}
164+
}
165+
155166
// Verify that files changed, we just do a git diff and check how many times version is added across files
156167
let numberOfChangedLinesWithNewVersion = exec(
157168
`git diff -U0 | grep '^[+]' | grep -c ${version} `,

scripts/update_podfile_lock.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This script updates RNTester Podfile.lock after verifying the CocoaPods environment.
8+
# Usage:
9+
# source scripts/update_podfile_lock && update_pods
10+
11+
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
12+
RNTESTER_DIR="$THIS_DIR/../packages/rn-tester"
13+
14+
# Note: Keep in sync with FB internal.
15+
REQUIRED_COCOAPODS_VERSION="1.10.1"
16+
17+
validate_env () {
18+
# Check that CocoaPods is working.
19+
if [ -z "$(command -v pod)" ]; then
20+
echo "You need to install CocoaPods."
21+
echo "See https://guides.cocoapods.org/using/getting-started.html#getting-started for instructions."
22+
exit 1
23+
fi
24+
25+
COCOAPODS_VERSION=$(pod --version)
26+
if [[ "$COCOAPODS_VERSION" != "$REQUIRED_COCOAPODS_VERSION" ]];
27+
then
28+
echo "You must have CocoaPods $REQUIRED_COCOAPODS_VERSION installed; you have $COCOAPODS_VERSION."
29+
echo "Installing via gem is recommended:"
30+
echo " sudo gem install cocoapods -v $REQUIRED_COCOAPODS_VERSION"
31+
exit 1
32+
fi
33+
}
34+
35+
update_pods () {
36+
validate_env
37+
38+
cd "$RNTESTER_DIR" || exit
39+
pod install
40+
cd "$THIS_DIR" || exit
41+
}

0 commit comments

Comments
 (0)