|
| 1 | +name: Build local libraries |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * *" |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - next |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - next |
| 14 | + merge_group: |
| 15 | + types: |
| 16 | + - checks_requested |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + env: |
| 24 | + XCODE_VERSION: 26 |
| 25 | + RCT_REMOVE_LEGACY_ARCH: 1 |
| 26 | + RCT_USE_RN_DEP: 1 |
| 27 | + RCT_USE_PREBUILT_RNCORE: 1 |
| 28 | + REACT_NATIVE_VERSION: 0.85.0 |
| 29 | + EXPO_SDK_VERSION: 55 |
| 30 | + APP_NAME: LocalLibraryApp |
| 31 | + LIBRARY_NAME: TestLibrary |
| 32 | + LIBRARY_DIR: modules/TestLibrary |
| 33 | + |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + os: |
| 38 | + - ubuntu-latest |
| 39 | + - macos-15 |
| 40 | + app: |
| 41 | + - community-cli |
| 42 | + - expo |
| 43 | + type: |
| 44 | + - name: turbo-module |
| 45 | + language: kotlin-objc |
| 46 | + - name: nitro-module |
| 47 | + language: kotlin-swift |
| 48 | + |
| 49 | + concurrency: |
| 50 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.app }}-${{ matrix.type.name }}-${{ matrix.type.language }} |
| 51 | + cancel-in-progress: true |
| 52 | + |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 58 | + |
| 59 | + - name: Setup |
| 60 | + uses: ./.github/actions/setup |
| 61 | + |
| 62 | + - name: Build package |
| 63 | + run: | |
| 64 | + yarn workspace create-react-native-library prepare |
| 65 | +
|
| 66 | + - name: Create app |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + if [[ "${{ matrix.app }}" == "community-cli" ]]; then |
| 70 | + npx @react-native-community/cli init "$APP_NAME" \ |
| 71 | + --directory "$APP_NAME" \ |
| 72 | + --version "$REACT_NATIVE_VERSION" \ |
| 73 | + --skip-install \ |
| 74 | + --skip-git-init \ |
| 75 | + --pm npm \ |
| 76 | + --package-name com.locallibraryapp |
| 77 | + else |
| 78 | + npx create-expo-app@latest "$APP_NAME" \ |
| 79 | + --no-install \ |
| 80 | + --template "blank@sdk-$EXPO_SDK_VERSION" |
| 81 | + fi |
| 82 | +
|
| 83 | + - name: Create local library |
| 84 | + working-directory: ${{ env.APP_NAME }} |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + ../packages/create-react-native-library/bin/create-react-native-library "$LIBRARY_NAME" \ |
| 88 | + --local \ |
| 89 | + --directory "$LIBRARY_DIR" \ |
| 90 | + --slug @bob/react-native-test \ |
| 91 | + --description test \ |
| 92 | + --type ${{ matrix.type.name }} \ |
| 93 | + --languages ${{ matrix.type.language }} |
| 94 | +
|
| 95 | + - name: Restore dependencies of app |
| 96 | + id: app-npm-cache |
| 97 | + uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ${{ env.APP_NAME }}/node_modules |
| 101 | + ${{ env.APP_NAME }}/package-lock.json |
| 102 | + key: ${{ runner.os }}-local-library-npm-${{ matrix.app }}-${{ matrix.type.name }}-${{ matrix.type.language }}-${{ hashFiles(format('{0}/package.json', env.APP_NAME), format('{0}/modules/**/package.json', env.APP_NAME)) }} |
| 103 | + restore-keys: | |
| 104 | + ${{ runner.os }}-local-library-npm-${{ matrix.app }}-${{ matrix.type.name }}-${{ matrix.type.language }}- |
| 105 | + ${{ runner.os }}-local-library-npm-${{ matrix.app }}- |
| 106 | +
|
| 107 | + - name: Install dependencies of app |
| 108 | + if: steps.app-npm-cache.outputs.cache-hit != 'true' |
| 109 | + working-directory: ${{ env.APP_NAME }} |
| 110 | + run: | |
| 111 | + npm install --no-audit --no-fund |
| 112 | +
|
| 113 | + - name: Cache dependencies of app |
| 114 | + if: steps.app-npm-cache.outputs.cache-hit != 'true' |
| 115 | + uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 116 | + with: |
| 117 | + path: | |
| 118 | + ${{ env.APP_NAME }}/node_modules |
| 119 | + ${{ env.APP_NAME }}/package-lock.json |
| 120 | + key: ${{ steps.app-npm-cache.outputs.cache-primary-key }} |
| 121 | + |
| 122 | + - name: Generate nitrogen code |
| 123 | + if: matrix.type.name == 'nitro-module' |
| 124 | + working-directory: ${{ env.APP_NAME }}/${{ env.LIBRARY_DIR }} |
| 125 | + shell: bash |
| 126 | + run: | |
| 127 | + nitro_version=$(node -p "require('../../package.json').dependencies['react-native-nitro-modules']") |
| 128 | + npm exec --yes --package "nitrogen@$nitro_version" -- nitrogen |
| 129 | +
|
| 130 | + - name: Install JDK |
| 131 | + if: runner.os == 'Linux' |
| 132 | + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 |
| 133 | + with: |
| 134 | + distribution: 'zulu' |
| 135 | + java-version: '17' |
| 136 | + |
| 137 | + - name: Finalize Android SDK |
| 138 | + if: runner.os == 'Linux' |
| 139 | + run: | |
| 140 | + /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" |
| 141 | +
|
| 142 | + - name: Prebuild Expo app (Android) |
| 143 | + if: runner.os == 'Linux' && matrix.app == 'expo' |
| 144 | + working-directory: ${{ env.APP_NAME }} |
| 145 | + run: | |
| 146 | + npx expo prebuild --platform android --non-interactive |
| 147 | +
|
| 148 | + - name: Cache Gradle |
| 149 | + if: runner.os == 'Linux' |
| 150 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 151 | + with: |
| 152 | + path: | |
| 153 | + ~/.gradle/wrapper |
| 154 | + ~/.gradle/caches |
| 155 | + key: ${{ runner.os }}-local-library-gradle-${{ matrix.app }}-${{ hashFiles(format('{0}/android/gradle/wrapper/gradle-wrapper.properties', env.APP_NAME)) }} |
| 156 | + restore-keys: | |
| 157 | + ${{ runner.os }}-local-library-gradle-${{ matrix.app }}- |
| 158 | + ${{ runner.os }}-local-library-gradle- |
| 159 | +
|
| 160 | + - name: Build app (Android) |
| 161 | + if: runner.os == 'Linux' |
| 162 | + working-directory: ${{ env.APP_NAME }} |
| 163 | + shell: bash |
| 164 | + env: |
| 165 | + JAVA_OPTS: "-XX:MaxHeapSize=6g" |
| 166 | + run: | |
| 167 | + if [[ "${{ matrix.app }}" == "community-cli" ]]; then |
| 168 | + npx react-native build-android --extra-params "--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a" |
| 169 | + else |
| 170 | + cd android |
| 171 | + ./gradlew assembleDebug -DtestBuildType=debug -Dorg.gradle.jvmargs=-Xmx4g -PreactNativeArchitectures=arm64-v8a --no-daemon --console=plain |
| 172 | + fi |
| 173 | +
|
| 174 | + - name: Use appropriate Xcode version |
| 175 | + if: runner.os == 'macOS' |
| 176 | + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 |
| 177 | + with: |
| 178 | + xcode-version: ${{ env.XCODE_VERSION }} |
| 179 | + |
| 180 | + - name: Prebuild Expo app (iOS) |
| 181 | + if: runner.os == 'macOS' && matrix.app == 'expo' |
| 182 | + working-directory: ${{ env.APP_NAME }} |
| 183 | + run: | |
| 184 | + npx expo prebuild --platform ios --non-interactive |
| 185 | +
|
| 186 | + - name: Install cocoapods |
| 187 | + if: runner.os == 'macOS' |
| 188 | + working-directory: ${{ env.APP_NAME }} |
| 189 | + shell: bash |
| 190 | + run: | |
| 191 | + if [[ -f Gemfile ]]; then |
| 192 | + bundle install |
| 193 | + bundle exec pod repo update --verbose |
| 194 | + bundle exec pod install --project-directory=ios |
| 195 | + else |
| 196 | + pod repo update --verbose |
| 197 | + pod install --project-directory=ios |
| 198 | + fi |
| 199 | +
|
| 200 | + - name: Build app (iOS) |
| 201 | + if: runner.os == 'macOS' |
| 202 | + working-directory: ${{ env.APP_NAME }} |
| 203 | + shell: bash |
| 204 | + run: | |
| 205 | + if [[ "${{ matrix.app }}" == "community-cli" ]]; then |
| 206 | + npx react-native build-ios --mode Debug |
| 207 | + else |
| 208 | + xcodebuild ONLY_ACTIVE_ARCH=YES \ |
| 209 | + -workspace "ios/$APP_NAME.xcworkspace" \ |
| 210 | + -UseNewBuildSystem=YES \ |
| 211 | + -scheme "$APP_NAME" \ |
| 212 | + -configuration Debug \ |
| 213 | + -sdk iphonesimulator \ |
| 214 | + -derivedDataPath ios/build \ |
| 215 | + -quiet |
| 216 | + fi |
0 commit comments