name: build-android description: This action builds android inputs: release-type: required: true description: The type of release we are building. It could be nightly, release or dry-run gradle-cache-encryption-key: description: "The encryption key needed to store the Gradle Configuration cache" runs: using: composite steps: - name: Setup git safe folders shell: bash run: git config --global --add safe.directory '*' - name: Setup node.js uses: ./.github/actions/setup-node - name: Install node dependencies uses: ./.github/actions/yarn-install - name: Set React Native Version shell: bash run: node ./scripts/releases/set-rn-artifacts-version.js --build-type ${{ inputs.release-type }} - name: Setup gradle uses: ./.github/actions/setup-gradle with: cache-read-only: "false" cache-encryption-key: ${{ inputs.gradle-cache-encryption-key }} - name: Restore Android ccache uses: actions/cache/restore@v4 with: path: /github/home/.cache/ccache key: v2-ccache-android-${{ github.job }}-${{ github.ref }}-${{ hashFiles('packages/react-native/ReactAndroid/**/*.cpp', 'packages/react-native/ReactAndroid/**/*.h', 'packages/react-native/ReactCommon/**/*.cpp', 'packages/react-native/ReactAndroid/**/CMakeLists.txt', 'packages/react-native/ReactCommon/**/CMakeLists.txt') }} restore-keys: | v2-ccache-android-${{ github.job }}-${{ github.ref }}- v2-ccache-android-${{ github.job }}- v2-ccache-android- - name: Show ccache stats shell: bash run: ccache -s -v - name: Build and publish all the Android Artifacts to /tmp/maven-local shell: bash run: | if [[ "${{ inputs.release-type }}" == "dry-run" ]]; then # dry-run: we only build ARM64 to save time/resources. For release/nightlies the default is to build all archs. export ORG_GRADLE_PROJECT_reactNativeArchitectures="arm64-v8a,x86" # x86 is required for E2E testing TASKS="publishAllToMavenTempLocal build" elif [[ "${{ inputs.release-type }}" == "nightly" ]]; then # nightly: we set isSnapshot to true so artifacts are sent to the right repository on Maven Central. export ORG_GRADLE_PROJECT_isSnapshot="true" TASKS="publishAllToMavenTempLocal publishAndroidToSonatype build" else # release: we want to build all archs (default) TASKS="publishAllToMavenTempLocal publishAndroidToSonatype build" fi ./gradlew $TASKS -PenableWarningsAsErrors=true - name: Save Android ccache if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} uses: actions/cache/save@v4 with: path: /github/home/.cache/ccache key: v2-ccache-android-${{ github.job }}-${{ github.ref }}-${{ hashFiles('packages/react-native/ReactAndroid/**/*.cpp', 'packages/react-native/ReactAndroid/**/*.h', 'packages/react-native/ReactCommon/**/*.cpp', 'packages/react-native/ReactAndroid/**/CMakeLists.txt', 'packages/react-native/ReactCommon/**/CMakeLists.txt') }} - name: Show ccache stats shell: bash run: ccache -s -v - name: Upload Maven Artifacts uses: actions/upload-artifact@v4.3.4 with: name: maven-local path: /tmp/maven-local - name: Upload test results if: ${{ always() }} uses: actions/upload-artifact@v4.3.4 with: name: build-android-results compression-level: 1 path: | packages/react-native-gradle-plugin/react-native-gradle-plugin/build/reports packages/react-native-gradle-plugin/settings-plugin/build/reports packages/react-native/ReactAndroid/build/reports - name: Upload RNTester APK - hermes-debug if: ${{ always() }} uses: actions/upload-artifact@v4.3.4 with: name: rntester-debug path: packages/rn-tester/android/app/build/outputs/apk/debug/ compression-level: 0 - name: Upload RNTester APK - hermes-release if: ${{ always() }} uses: actions/upload-artifact@v4.3.4 with: name: rntester-release path: packages/rn-tester/android/app/build/outputs/apk/release/ compression-level: 0