Skip to content

workflow (rn): enable corepack before using node #21

workflow (rn): enable corepack before using node

workflow (rn): enable corepack before using node #21

Workflow file for this run

name: Build an Android APK
on:
push:
paths:
- '*'
- '.github/workflows/build-android.yml'
- 'android/**'
- '!**/*.md'
- '!ios/**'
branches:
- react-native
jobs:
build-rn-android:
permissions:
contents: write
name: Build Android APK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Optional security step: Validate whether gradle-wrapper.jar is valid or malicious
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
# 'corepack enable' is needed for now till it's experimental, may remove the command once it becomes stable in later node releases
- name: Enable Corepack
run: corepack enable
# Setup Web environment to install packages.
- name: Setup Web environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
# Setup Java environment in order to build the Android app.
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
# Setup gradle using official gradle action
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
add-job-summary: 'on-failure'
# Optional: Only write to the cache for builds on the 'main' and 'react-native' branches. (Default is 'main' only.)
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/react-native' }}
# Here '--immutable' will only use commited 'yarn.lock', and will throw error if some update is needed
- name: Install node_modules
run: yarn install --immutable
# In some cases, Gradle is not executable by default, so we do this before the build process
- name: Make gradlew executable
working-directory: android
run: chmod +x ./gradlew
- name: Build Android release APK
working-directory: android
run: ./gradlew assembleRelease
- name: Save apk file as artifact
uses: actions/upload-artifact@v4
with:
name: rn-actions-test
path: android/app/build/outputs/apk/release/app-release.apk