Files
LensApp/.github/workflows/build-android.yml
Rakshit Kumar Singh e61ca8a629 enulator test (#1)
* enulator test

* enulator fix

* fix adb name

* fix path for detox

* fix bundeling

* fix api

* fix path

* fix path

* path

* path

* path

* path

* fix: start Metro before emulator-runner to avoid pipe block

* add bare-minimum e2e workflow using release build (no Metro)

* fix: use debug instrumentation APK against release app build

* fix: add Detox androidTest dep and testInstrumentationRunner, use debug build

* fix: add version to detox androidTestImplementation

* fix: add Detox local Maven repo to allprojects

* fix: remove androidTestImplementation detox, not needed with auto-linking

* fix: add androidx.test:runner to provide AndroidJUnitRunner in test APK

* fix: add proper Detox test class and dependency with exclusiveContent

* fix: correct Detox maven coordinate to com.wix:detox

* fix: override Detox minSdk 24 requirement for androidTest

* remove viewer.e2e.ts, requires launch args bridge not yet wired up

* cleanup: remove E2E from build-android workflow, revert release detox config

* update github action

* enable ABI splits for smaller per-arch release APKs

* fix: move abiCodes into closure scope

* fix: only split release builds, keep universal debug APK for E2E
2026-04-18 22:32:40 +05:30

113 lines
3.7 KiB
YAML

name: Build Android
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
build_type:
description: Build type (debug or release)
required: false
default: release
type: choice
options: [debug, release]
jobs:
build:
name: Build ${{ github.event.inputs.build_type || 'release' }} APK
runs-on: ubuntu-latest
env:
# User-writable path avoids tar permission errors when restoring the cache.
# Both vars must point to the same place — Gradle errors if they differ.
ANDROID_HOME: /home/runner/android-sdk
ANDROID_SDK_ROOT: /home/runner/android-sdk
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
# Cache SDK in a user-writable home path so tar can restore permissions.
# Keyed on build.gradle so bumping compileSdkVersion/buildToolsVersion
# automatically invalidates the cache and installs the new versions.
- name: Cache Android SDK components
id: cache-android-sdk
uses: actions/cache@v5
with:
path: /home/runner/android-sdk
key: android-sdk-${{ hashFiles('android/build.gradle') }}
- name: Install Android SDK components
if: steps.cache-android-sdk.outputs.cache-hit != 'true'
run: |
mkdir -p $ANDROID_HOME/cmdline-tools
curl -sSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o cmdline-tools.zip
unzip -q cmdline-tools.zip -d $ANDROID_HOME/cmdline-tools
mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME \
"platforms;android-35" "build-tools;35.0.0" "platform-tools"
- name: Cache Gradle
uses: actions/cache@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
android/.gradle
key: gradle-${{ hashFiles('android/gradle/wrapper/gradle-wrapper.properties', 'android/**/*.gradle') }}
restore-keys: gradle-
- name: Run JS tests
run: npx jest src/__tests__ --no-coverage
- name: Make gradlew executable
run: chmod +x android/gradlew
- name: Bundle JS
run: |
mkdir -p android/app/src/main/assets
npx react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--bundle-output android/app/src/main/assets/index.android.bundle \
--assets-dest android/app/src/main/res
- name: Build APK
working-directory: android
run: ./gradlew assemble$(echo "${BUILD_TYPE^}") --no-daemon
env:
BUILD_TYPE: ${{ github.event.inputs.build_type || 'release' }}
- name: Upload APK artifact
uses: actions/upload-artifact@v7
with:
name: LensApp-${{ github.event.inputs.build_type || 'release' }}-${{ github.run_number }}
path: android/app/build/outputs/apk/${{ github.event.inputs.build_type || 'release' }}/*.apk
retention-days: 30