/
githubmirror
/
react-native
Обзор
Документация
Войти
/
githubmirror
/
react-native
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
.github/actions/build-android/action.yml
108 строк
6 KB
Nicola Corti
Split Android build from release publishing (#57714)
29 июл 2026, 00:03
29 июл 2026, 00:03
a44d68e
Код
Авторство
О чём код?
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: Read current RNVersion shell: bash id: read-rn-version run: | echo "rn-version=$(jq -r '.version' packages/react-native/package.json)" >> $GITHUB_OUTPUT - name: Set React Native Version # We don't want to set the version for stable branches, because this has been # already set from the 'create release' commits on the release branch. # For testing RC.0, though, the version has not been set yet. In that case, we are on Stable branch and # it is the only case when the version is still 1000.0.0 # We also skip this when the PR targets a stable branch (github.base_ref ends with '-stable'), # since the version is already set on the stable branch. if: ${{ !endsWith(github.ref_name, '-stable') && !endsWith(github.base_ref || '', '-stable') || endsWith(github.ref_name, '-stable') && steps.read-rn-version.outputs.rn-version == '1000.0.0' }} 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@v5 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 export HERMES_PREBUILT_FLAG="ORG_GRADLE_PROJECT_react.internal.useHermesNightly=true" 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" export HERMES_PREBUILT_FLAG="ORG_GRADLE_PROJECT_react.internal.useHermesNightly=true" TASKS="publishAllToMavenTempLocal publishAndroidToSonatype build" else # release: build all archs and close the repository so that Sonatype can validate it. # Releasing to Maven Central happens only after the Apple builds succeed. export HERMES_PREBUILT_FLAG="ORG_GRADLE_PROJECT_react.internal.useHermesStable=true" TASKS="publishAllToMavenTempLocal publishAndroidToSonatype closeSonatypeStagingRepository build" fi env "$HERMES_PREBUILT_FLAG" ./gradlew $TASKS -PenableWarningsAsErrors=true - name: Save Android ccache if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} uses: actions/cache/save@v5 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@v6 with: name: maven-local path: /tmp/maven-local - name: Upload test results if: ${{ always() }} uses: actions/upload-artifact@v6 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@v6 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@v6 with: name: rntester-release path: packages/rn-tester/android/app/build/outputs/apk/release/ compression-level: 0