Test React Native nightly build for Expo Modules #62
This file contains 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
name: Test React Native nightly build for Expo Modules | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: '0 3 * * *' # 03:00 AM UTC everyday | |
push: | |
branches: [main] | |
paths: | |
- .github/workflows/test-react-native-nightly.yml | |
pull_request: | |
paths: | |
- .github/workflows/test-react-native-nightly.yml | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
ios-build: | |
strategy: | |
fail-fast: true | |
matrix: | |
build-type: [debug, release] | |
runs-on: macos-14 | |
steps: | |
- name: 👀 Checkout | |
uses: actions/checkout@v4 | |
- name: 🔨 Switch to Xcode 15.2 | |
run: sudo xcode-select --switch /Applications/Xcode_15.2.app | |
- name: 🍺 Install required tools | |
run: | | |
brew install watchman || true | |
- name: 🚀 Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: 💎 Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.2.2 | |
- name: 💎 Install Ruby gems | |
run: gem install 'cocoapods:1.14.3' xcpretty | |
- name: ♻️ Restore workspace node modules | |
# Use restore only cache here because we don't want to nightly react-native version saving back to the cache | |
uses: actions/cache/restore@v3 | |
id: workspace-modules-cache | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
packages/@expo/*/node_modules | |
key: ${{ runner.os }}-workspace-modules-${{ hashFiles('yarn.lock') }} | |
- name: 🧶 Install node modules in root dir | |
if: steps.workspace-modules-cache.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: ⭐️ Create test-nightlies Project | |
run: yarn prepare && bun build/index.js --expo-repo ${{ github.workspace }} --no-install ${{ runner.temp }} | |
working-directory: packages/create-expo-nightly | |
- name: 🍏 Query available simulator device ID | |
run: | | |
echo "Available simulators" | |
xcrun simctl list devices available -j | jq -r '.devices | to_entries[] | select(.value | length > 0)' | |
DEVICE_ID=$(defaults read com.apple.iphonesimulator CurrentDeviceUDID || xcrun simctl list devices available -j | jq -r '.devices | to_entries[] | select(.value | length > 0) | select(.key | startswith("com.apple.CoreSimulator.SimRuntime.iOS")) | .value[] | select(.isAvailable == true) | .udid' | head -n 1) | |
echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV | |
- name: 🍏 Build iOS Project | |
run: | | |
pod install --project-directory=ios | |
xcodebuild -workspace ios/testnightlies.xcworkspace -scheme testnightlies -configuration $CONFIGURATION -sdk iphonesimulator -destination "id=$DEVICE_ID" -derivedDataPath "ios/build" | xcpretty | |
shell: bash | |
working-directory: ${{ runner.temp }}/test-nightlies | |
env: | |
NODE_ENV: production | |
CONFIGURATION: ${{ matrix.build-type == 'release' && 'Release' || 'Debug' }} | |
- name: 📸 Upload builds | |
uses: actions/upload-artifact@v4 | |
if: ${{ github.event_name == 'workflow_dispatch' && matrix.build-type == 'release' }} # Only archive release builds | |
with: | |
name: ios-builds-oldArch-${{ matrix.build-type }} | |
path: ${{ runner.temp }}/test-nightlies/ios/build/**/testnightlies.app/ | |
- name: 🍏 Build iOS Project (New Architecture) | |
run: | | |
jq '.expo.plugins[] |= (if (type == "array" and .[0] == "expo-build-properties") then .[1].ios.newArchEnabled = true else . end)' app.json > app.json.tmp | |
mv -f app.json.tmp app.json | |
cat app.json | |
npx expo prebuild -p ios --no-install --template expo-template-bare-minimum-*.tgz | |
pod install --project-directory=ios | |
xcodebuild -workspace ios/testnightlies.xcworkspace -scheme testnightlies -configuration $CONFIGURATION -sdk iphonesimulator -destination "id=$DEVICE_ID" -derivedDataPath "ios/build" | xcpretty | |
shell: bash | |
working-directory: ${{ runner.temp }}/test-nightlies | |
env: | |
NODE_ENV: production | |
CONFIGURATION: ${{ matrix.build-type == 'release' && 'Release' || 'Debug' }} | |
- name: 📸 Upload builds | |
uses: actions/upload-artifact@v4 | |
if: ${{ github.event_name == 'workflow_dispatch' && matrix.build-type == 'release' }} # Only archive release builds | |
with: | |
name: ios-builds-newArch-${{ matrix.build-type }} | |
path: ${{ runner.temp }}/test-nightlies/ios/build/**/testnightlies.app/ | |
- name: 🔔 Notify on Slack | |
uses: 8398a7/action-slack@v3 | |
if: failure() && (github.event_name == 'schedule' || github.event.ref == 'refs/heads/main') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_ios }} | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
with: | |
channel: '#expo-ios' | |
status: ${{ job.status }} | |
fields: job,message,ref,eventName,author,took | |
author_name: React Native Nightly (iOS) | |
android-build: | |
strategy: | |
fail-fast: true | |
matrix: | |
build-type: [debug, release] | |
runs-on: ubuntu-22.04 | |
env: | |
ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64 | |
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=4096m" | |
steps: | |
- name: 👀 Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: 🚀 Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: 🔨 Use JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: ♻️ Restore workspace node modules | |
# Use restore only cache here because we don't want to nightly react-native version saving back to the cache | |
uses: actions/cache/restore@v3 | |
id: workspace-modules-cache | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
packages/@expo/*/node_modules | |
key: ${{ runner.os }}-workspace-modules-${{ hashFiles('yarn.lock') }} | |
- name: 🧶 Install node modules in root dir | |
if: steps.workspace-modules-cache.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: ⭐️ Create test-nightlies Project | |
run: yarn prepare && bun build/index.js --expo-repo ${{ github.workspace }} --no-install ${{ runner.temp }} | |
working-directory: packages/create-expo-nightly | |
- name: 🤖 Build Android project | |
run: | | |
cd android && ./gradlew ":app:assemble$VARIANT" | |
shell: bash | |
working-directory: ${{ runner.temp }}/test-nightlies | |
env: | |
NODE_ENV: production | |
VARIANT: ${{ matrix.build-type == 'release' && 'Release' || 'Debug' }} | |
- name: 📸 Upload builds | |
uses: actions/upload-artifact@v4 | |
if: ${{ github.event_name == 'workflow_dispatch' && matrix.build-type == 'release' }} # Only archive release builds | |
with: | |
name: android-builds-oldArch-${{ matrix.build-type }} | |
path: ${{ runner.temp }}/test-nightlies/android/app/build/outputs/apk/ | |
- name: 🤖 Build Android project (New Architecture) | |
run: | | |
jq '.expo.plugins[] |= (if (type == "array" and .[0] == "expo-build-properties") then .[1].android.newArchEnabled = true else . end)' app.json > app.json.tmp | |
mv -f app.json.tmp app.json | |
cat app.json | |
npx expo prebuild -p ios --no-install --template expo-template-bare-minimum-*.tgz | |
cd android && ./gradlew ":app:assemble$VARIANT" | |
shell: bash | |
working-directory: ${{ runner.temp }}/test-nightlies | |
env: | |
NODE_ENV: production | |
VARIANT: ${{ matrix.build-type == 'release' && 'Release' || 'Debug' }} | |
- name: 📸 Upload builds | |
uses: actions/upload-artifact@v4 | |
if: ${{ github.event_name == 'workflow_dispatch' && matrix.build-type == 'release' }} # Only archive release builds | |
with: | |
name: android-builds-newArch-${{ matrix.build-type }} | |
path: ${{ runner.temp }}/test-nightlies/android/app/build/outputs/apk/ | |
- name: 🔔 Notify on Slack | |
uses: 8398a7/action-slack@v3 | |
if: failure() && (github.event_name == 'schedule' || github.event.ref == 'refs/heads/main') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_android }} | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
with: | |
channel: '#expo-android' | |
status: ${{ job.status }} | |
fields: job,message,ref,eventName,author,took | |
author_name: React Native Nightly (Android) |