- actions/setup-node cache: npm - actions/cache for ~/.gradle/caches, ~/.gradle/wrapper, android/.gradle - actions/cache for Android intermediates (android/app/build/intermediates, android/build, android/app/.cxx) - Skip debug keystore regeneration if cached - Add workflow_dispatch to publish-play-store for manual re-runs Cuts a clean run from ~6m to ~2-3m once warm. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
94 lines
2.6 KiB
YAML
94 lines
2.6 KiB
YAML
name: Build Android APK
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
EXPO_PUBLIC_SENTRY_DSN: ${{ secrets.EXPO_PUBLIC_SENTRY_DSN }}
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
|
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
|
|
- uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
android/.gradle
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('android/**/*.gradle*', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
|
|
- name: Cache Android build outputs
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
android/app/build/intermediates
|
|
android/build
|
|
android/app/.cxx
|
|
key: ${{ runner.os }}-android-build-${{ hashFiles('package-lock.json', 'android/**/*.gradle*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-android-build-
|
|
|
|
- name: Install dependencies
|
|
run: npm install --legacy-peer-deps
|
|
|
|
- name: Expo prebuild
|
|
run: npx expo prebuild --platform android --no-install
|
|
|
|
- name: Generate debug keystore
|
|
run: |
|
|
if [ ! -f android/app/debug.keystore ]; then
|
|
keytool -genkey -v -keystore android/app/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
|
|
fi
|
|
|
|
- name: Build APK
|
|
working-directory: android
|
|
run: ./gradlew assembleRelease
|
|
|
|
- name: Upload APK artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: app-release
|
|
path: android/app/build/outputs/apk/release/app-release.apk
|
|
|
|
release:
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: app-release
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: app-release.apk
|
|
generate_release_notes: true
|