Created
July 7, 2025 14:23
-
-
Save bmorrisondev/32357a31610815703b5ea719e6295ec4 to your computer and use it in GitHub Desktop.
Scripts to build a React Native app for iOS and ship to Test Flight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| FOLDER_PATH="./build" | |
| # Create a build folder for artifacts | |
| if [ ! -d "$FOLDER_PATH" ]; then | |
| mkdir -p "$FOLDER_PATH" | |
| fi | |
| # Build the thing | |
| pnpx eas-cli build -p ios --profile production --local --clear-cache --non-interactive | |
| # Get the filename of the latest build | |
| LATEST_BUILD=$(ls -t build-* 2>/dev/null | head -1) | |
| # Move the file into the build dir and deploy it to the device | |
| if [ -n "$LATEST_BUILD" ]; then | |
| mv $LATEST_BUILD $FOLDER_PATH/prod-$LATEST_BUILD | |
| else | |
| echo "No builds found." | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e # Exit immediately if a command exits with a non-zero status | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" | |
| FOLDER_PATH="$PROJECT_ROOT/build" | |
| echo "π¦ Looking for builds in: $FOLDER_PATH" | |
| # Check if fastlane is installed | |
| if ! command -v fastlane &> /dev/null; then | |
| echo "β Error: fastlane is not installed. Please install it using 'gem install fastlane'." | |
| exit 1 | |
| fi | |
| # Get the filename of the latest production build | |
| LATEST_BUILD=$(ls -t "$FOLDER_PATH"/prod-build-*.ipa 2>/dev/null | head -1) | |
| # Upload the latest production build to TestFlight | |
| if [ -n "$LATEST_BUILD" ]; then | |
| echo "β Found build: $LATEST_BUILD" | |
| echo "π€ Uploading to TestFlight..." | |
| # Check if the file exists and is readable | |
| if [ ! -r "$LATEST_BUILD" ]; then | |
| echo "β Error: Build file not readable or doesn't exist: $LATEST_BUILD" | |
| exit 1 | |
| fi | |
| # Try to upload with a timeout to prevent hanging | |
| echo "π Starting upload with fastlane pilot..." | |
| if fastlane pilot upload --ipa "$LATEST_BUILD" --skip_submission \ | |
| --skip_waiting_for_build_processing \ | |
| --username $FASTLANE_USERNAME; then | |
| echo "β Upload complete! The build will be processed by TestFlight shortly." | |
| else | |
| echo "β Upload failed. Check the error messages above." | |
| exit 1 | |
| fi | |
| else | |
| echo "β No production builds found. Make sure to run build-prod.sh first." | |
| exit 1 | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here are the relevant env vars set in my terminal: