Skip to content

Instantly share code, notes, and snippets.

@bmorrisondev
Created July 7, 2025 14:23
Show Gist options
  • Select an option

  • Save bmorrisondev/32357a31610815703b5ea719e6295ec4 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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
#!/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
@bmorrisondev
Copy link
Author

Here are the relevant env vars set in my terminal:

export FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=
export FASTLANE_ITC_TEAM_ID=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment