-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbump-version.sh
More file actions
executable file
·94 lines (83 loc) · 3.29 KB
/
bump-version.sh
File metadata and controls
executable file
·94 lines (83 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Prompt for the new React SDK version
read -rp "Enter the new React SDK version: " new_version
# Update SDK version in package.json
if [[ -f "package.json" ]]; then
jq --arg newVersion "$new_version" '.version = $newVersion' package.json > tmp.json && mv tmp.json package.json
echo "Updated SDK version in package.json."
else
echo "Error: package.json not found."
exit 1
fi
# Update klaviyo_sdk_version in iOS plist file
plist_file="ios/klaviyo-sdk-configuration.plist"
if [[ -f "$plist_file" ]]; then
/usr/libexec/PlistBuddy -c "Set :klaviyo_sdk_version $new_version" "$plist_file"
echo "Updated klaviyo_sdk_version in $plist_file."
else
echo "Error: $plist_file not found."
exit 1
fi
# Update klaviyo_sdk_version_override in Android strings.xml
android_strings="android/src/main/res/values/strings.xml"
if [[ -f "$android_strings" ]]; then
sed -i '' "s/<string name=\"klaviyo_sdk_version_override\">.*<\/string>/<string name=\"klaviyo_sdk_version_override\">$new_version<\/string>/" "$android_strings"
echo "Updated klaviyo_sdk_version_override in $android_strings."
else
echo "Error: $android_strings not found."
exit 1
fi
# Prompt for the Android SDK version
read -rp "Enter the Android SDK version: " android_version
# Update Android SDK version in gradle.properties
gradle_properties="./android/gradle.properties"
if [[ -f "$gradle_properties" ]]; then
sed -i '' "s/KlaviyoReactNativeSdk_klaviyoAndroidSdkVersion=.*/KlaviyoReactNativeSdk_klaviyoAndroidSdkVersion=$android_version/" "$gradle_properties"
echo "Updated Android SDK version in $gradle_properties."
else
echo "Error: $gradle_properties not found."
exit 1
fi
# Prompt for the Swift SDK version
read -rp "Enter the Swift SDK version: " swift_version
# Update Swift SDK version in the podspec
podspec_file="klaviyo-react-native-sdk.podspec"
if [[ -f "$podspec_file" ]]; then
sed -i '' "s/\"KlaviyoSwift\", \".*\"/\"KlaviyoSwift\", \"$swift_version\"/" "$podspec_file"
sed -i '' "s/\"KlaviyoForms\", \".*\"/\"KlaviyoForms\", \"$swift_version\"/" "$podspec_file"
sed -i '' "s/\"KlaviyoLocation\", \".*\"/\"KlaviyoLocation\", \"$swift_version\"/" "$podspec_file"
echo "Updated KlaviyoSwift, KlaviyoForms, and KlaviyoLocation version in $podspec_file."
else
echo "Error: $podspec_file not found."
exit 1
fi
# Run yarn install or npm install in the example app directory
example_dir="example"
if [[ -d "$example_dir" ]]; then
echo "Running yarn install in $example_dir..."
cd "$example_dir" || exit
if ! yarn install; then
echo "yarn install failed. Trying npm install..."
npm install || { echo "Error: Failed to install dependencies."; exit 1; }
fi
cd - || exit
else
echo "Error: $example_dir not found."
exit 1
fi
# Run bundle install and pod update in the iOS directory
ios_dir="$example_dir/ios"
if [[ -d "$ios_dir" ]]; then
cd "$ios_dir" || exit
if [[ -f "Gemfile" ]]; then
echo "Running bundle install..."
bundle install || { echo "Error: Failed to run bundle install."; exit 1; }
fi
echo "Running pod update for KlaviyoSwift, KlaviyoForms, and KlaviyoLocation..."
bundle exec pod update KlaviyoSwift KlaviyoForms KlaviyoLocation || { echo "Error: Failed to update pods."; exit 1; }
cd - || exit
else
echo "Error: $ios_dir not found."
exit 1
fi
echo "All tasks completed successfully."