Files
react-native/.github/actions/build-android/action.yml
Nicola Corti 2ca01b4d04 Revert "Remove unnecessary git config --global --add safe.directory" (#45929)
Summary:
This reverts commit 9d9a8d2df6.

## Changelog:

[INTERNAL] - This reverts commit 9d9a8d2df6.

Pull Request resolved: https://github.com/facebook/react-native/pull/45929

Test Plan: CI

Reviewed By: blakef

Differential Revision: D60901502

Pulled By: cortinico

fbshipit-source-id: 2b7a7908a29f031c1f229907aa899a8a6960da4b
2024-08-07 06:39:31 -07:00

110 lines
4.3 KiB
YAML

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
run-e2e-tests:
default: 'false'
description: If we need to build to run E2E tests. If yes, we need to build also x86.
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-with-cache
- 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"
- name: Restore Android ccache
uses: actions/cache/restore@v4
with:
path: /github/home/.cache/ccache
key: v1-ccache-android-${{ github.job }}-${{ github.ref }}
restore-keys: |
v1-ccache-android-${{ github.job }}-
v1-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.
if [[ "${{ inputs.run-e2e-tests }}" == 'true' ]]; then
export ORG_GRADLE_PROJECT_reactNativeArchitectures="arm64-v8a,x86" # x86 is required for E2E testing
else
export ORG_GRADLE_PROJECT_reactNativeArchitectures="arm64-v8a"
fi
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: v1-ccache-android-${{ github.job }}-${{ github.ref }}
- 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-hermes-debug
path: packages/rn-tester/android/app/build/outputs/apk/hermes/debug/
compression-level: 0
- name: Upload RNTester APK - hermes-release
if: ${{ always() }}
uses: actions/upload-artifact@v4.3.4
with:
name: rntester-hermes-release
path: packages/rn-tester/android/app/build/outputs/apk/hermes/release/
compression-level: 0
- name: Upload RNTester APK - jsc-debug
if: ${{ always() }}
uses: actions/upload-artifact@v4.3.4
with:
name: rntester-jsc-debug
path: packages/rn-tester/android/app/build/outputs/apk/jsc/debug/
compression-level: 0
- name: Upload RNTester APK - jsc-release
if: ${{ always() }}
uses: actions/upload-artifact@v4.3.4
with:
name: rntester-jsc-release
path: packages/rn-tester/android/app/build/outputs/apk/jsc/release/
compression-level: 0