-
Notifications
You must be signed in to change notification settings - Fork 111
Add local build script build.sh #1743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Builds the React Native SDK. | ||
| # | ||
| # Usage: | ||
| # ./build.sh Build the full SDK stack: JS/web, iOS, and Android. | ||
| # ./build.sh ios Install JS dependencies and pods, then build JS and the iOS example workspace. | ||
| # ./build.sh android Install JS dependencies, then build JS and Android. | ||
| # ./build.sh web Install JS dependencies, then build the web/Expo package. | ||
| # | ||
| # Valid platforms: ios, android, web | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 [ios|android|web]" | ||
| } | ||
|
|
||
| if [ "$#" -gt 1 ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| platform="${1:-}" | ||
|
|
||
| build_js_sdk() { | ||
| yarn build | ||
| } | ||
|
|
||
| install_js_dependencies() { | ||
| yarn | ||
| } | ||
|
|
||
| install_ios_dependencies() { | ||
| yarn example pods | ||
| } | ||
|
|
||
| build_web_sdk() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this doesn't only build the web sdk, but it does build our SDKs for all platforms (and prepares it to be used by our purchase tester expo app)... Additionally, it's quite confusing with the |
||
| yarn prepare-expo | ||
| } | ||
|
|
||
| is_xcpretty_installed() { | ||
| command -v xcpretty >/dev/null 2>&1 | ||
| } | ||
|
|
||
| compile_ios_sdk_and_purchase_tester() { | ||
| if is_xcpretty_installed; then | ||
| xcodebuild \ | ||
| -workspace examples/purchaseTesterTypescript/ios/PurchaseTester.xcworkspace \ | ||
| -scheme PurchaseTester \ | ||
| -configuration Debug \ | ||
| -sdk iphonesimulator \ | ||
| -destination "generic/platform=iOS Simulator" \ | ||
| build | xcpretty | ||
| else | ||
| xcodebuild \ | ||
| -workspace examples/purchaseTesterTypescript/ios/PurchaseTester.xcworkspace \ | ||
| -scheme PurchaseTester \ | ||
| -configuration Debug \ | ||
| -sdk iphonesimulator \ | ||
| -destination "generic/platform=iOS Simulator" \ | ||
| build | ||
| fi | ||
| } | ||
|
|
||
| compile_android_sdk_and_purchase_tester() { | ||
| ( | ||
| cd examples/purchaseTesterTypescript/android | ||
| ./gradlew :react-native-purchases:assembleDebug | ||
| ) | ||
| } | ||
|
|
||
| case "$platform" in | ||
| "") | ||
| echo "About to build the RevenueCat React Native SDK for all platforms." | ||
| yarn bootstrap | ||
| compile_ios_sdk_and_purchase_tester | ||
| compile_android_sdk_and_purchase_tester | ||
| ;; | ||
| ios) | ||
| echo "About to build the RevenueCat React Native SDK for iOS only." | ||
| install_js_dependencies | ||
| install_ios_dependencies | ||
| build_js_sdk | ||
| compile_ios_sdk_and_purchase_tester | ||
| ;; | ||
| android) | ||
| echo "About to build the RevenueCat React Native SDK for Android only." | ||
| install_js_dependencies | ||
| build_js_sdk | ||
| compile_android_sdk_and_purchase_tester | ||
| ;; | ||
| web) | ||
| echo "About to build the RevenueCat React Native SDK for web only." | ||
| install_js_dependencies | ||
| build_web_sdk | ||
| ;; | ||
| *) | ||
| echo "Invalid platform: $platform" | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| echo "Done building the RevenueCat React Native SDK." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought... But should we do all this in fastlane instead of a shell script? It might be easier to share some things if we do it there... On the other hand, it's true that it requires to setup ruby + all those dependencies, but considering this is mostly meant for developers which should already be using fastlane, I think that might be ok? One thing that I think we would need to do for this to work though (and we probably should have setup a long time ago...). We would need to setup Wdyt @RevenueCat/coresdk? I'm not too opposed to go to shell script if needed... But just feels like ruby/javascript are nicer to work with |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done in a separate PR but could be nice to add commands to actually run the sample apps as well... Though in this case, maybe it shouldn't be in
build.shbut a different script 😅