|
| 1 | +name: Build App |
| 2 | +description: 'Set up your GitHub Actions workflow with a specific version of Node.js' |
| 3 | +inputs: |
| 4 | + new-arch-enabled: |
| 5 | + description: 'Enable new architecture (example: 1 or 0))' |
| 6 | + required: true |
| 7 | + |
| 8 | + rn-ver: |
| 9 | + description: 'Version of React Native (example: 0.72.6))' |
| 10 | + required: true |
| 11 | + |
| 12 | + arch: |
| 13 | + description: 'Architecture (example: "arm64-v8a" or "x86_64,arm64-v8a") android only' |
| 14 | + required: false |
| 15 | + default: 'armeabi-v7a,arm64-v8a,x86,x86_64' |
| 16 | + |
| 17 | + module-to-install: |
| 18 | + description: 'Module to install (example: "react-native-architectures" or "file:/path/to/module"))' |
| 19 | + required: true |
| 20 | + |
| 21 | + store-artifacts: |
| 22 | + description: 'Store artifacts on GitHub (example: true or false))' |
| 23 | + required: false |
| 24 | + default: 'true' |
| 25 | + |
| 26 | + platform: |
| 27 | + description: 'Platform (example: android or ios))' |
| 28 | + required: true |
| 29 | + |
| 30 | + |
| 31 | +runs: |
| 32 | + using: 'composite' |
| 33 | + steps: |
| 34 | + - uses: ./.github/actions/lock-nodejs-ver |
| 35 | + |
| 36 | + - uses: ./.github/actions/lock-java-ver |
| 37 | + if: ${{ inputs.platform == 'android' }} |
| 38 | + |
| 39 | + - uses: ./.github/actions/lock-ruby-ver |
| 40 | + if: ${{ inputs.platform == 'ios' }} |
| 41 | + |
| 42 | + - name: Create tmp directory |
| 43 | + shell: bash |
| 44 | + id: clear_name |
| 45 | + env: |
| 46 | + APP_NAME: Example${{ inputs.rn-ver }}${{ inputs.new-arch-enabled }}App |
| 47 | + run: | |
| 48 | + input_string="${{ env.APP_NAME }}" |
| 49 | +
|
| 50 | + # Remove "." and "-" symbols from the input string |
| 51 | + modified_string="${input_string//./}" |
| 52 | + modified_string="${modified_string//-/}" |
| 53 | +
|
| 54 | + echo "folder=${modified_string}" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + - name: Build ${{ inputs.platform }} (${{ inputs.arch }}) |
| 57 | + working-directory: /tmp |
| 58 | + shell: bash |
| 59 | + id: app_build |
| 60 | + env: |
| 61 | + APP_NAME: ${{ steps.clear_name.outputs.folder }} |
| 62 | + # iOS only |
| 63 | + NO_FLIPPER: 1 |
| 64 | + RCT_NEW_ARCH_ENABLED: ${{ inputs.new-arch-enabled }} |
| 65 | + run: | |
| 66 | + set -x # print all executed commands |
| 67 | +
|
| 68 | + # Create new tmp React Native project |
| 69 | + npx react-native@${{ inputs.rn-ver }} init ${{ env.APP_NAME }} --version ${{ inputs.rn-ver }} |
| 70 | + cd ${{ env.APP_NAME }} |
| 71 | +
|
| 72 | + # Install my module |
| 73 | + yarn add ${{ inputs.module-to-install }} |
| 74 | +
|
| 75 | + # Debug info |
| 76 | + npx react-native@${{ inputs.rn-ver }} info |
| 77 | +
|
| 78 | + if [[ '${{ inputs.platform }}' == 'ios' ]]; then |
| 79 | + brew install xcbeautify |
| 80 | +
|
| 81 | + # Update pods after adding new module |
| 82 | + npx pod-install |
| 83 | + |
| 84 | + # Build iOS App |
| 85 | + xcodebuild -scheme ${{ env.APP_NAME }} -workspace ios/${{ env.APP_NAME }}.xcworkspace -configuration Release -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' | xcbeautify --quiet |
| 86 | + |
| 87 | + # set output variable |
| 88 | + echo "app_path=$(find ~/Library/Developer/Xcode/DerivedData -type d -name "${{ env.APP_NAME }}.app")" >> $GITHUB_OUTPUT |
| 89 | + else |
| 90 | + # Enable new arch for Android |
| 91 | + if [[ '${{ inputs.new-arch-enabled }}' == '1' ]]; then |
| 92 | + sed -i 's/newArchEnabled=false/newArchEnabled=true/' android/gradle.properties |
| 93 | + fi |
| 94 | +
|
| 95 | + # Build Android |
| 96 | + ./android/gradlew assembleRelease --no-daemon -p android -PreactNativeArchitectures=${{ inputs.arch }} |
| 97 | + |
| 98 | + # set output variable |
| 99 | + echo "app_path=$(find $(pwd)/android -type f -name '*.apk')" >> $GITHUB_OUTPUT |
| 100 | + fi |
| 101 | +
|
| 102 | + - name: Store Android artifacts on GitHub |
| 103 | + uses: actions/upload-artifact@v3 |
| 104 | + if: ${{ inputs.store-artifacts == 'true' }} |
| 105 | + with: |
| 106 | + name: ${{ inputs.platform }}-${{ inputs.rn-ver }}-newArch${{ inputs.new-arch-enabled }} |
| 107 | + if-no-files-found: error |
| 108 | + retention-days: 14 # 2 weeks |
| 109 | + path: ${{ steps.app_build.outputs.app_path }} |
0 commit comments