Build Android APK #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android APK | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: "Release tag to attach APK to (optional)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-android: | |
| name: Build Android APK | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "17" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Typecheck | |
| run: bunx tsc --noEmit | |
| - name: Prebuild Android project | |
| run: bunx expo prebuild --platform android --clean | |
| - name: Enable ProGuard and ABI splits | |
| run: | | |
| # Enable ProGuard/R8 minification and per-ABI split | |
| cat >> android/app/build.gradle << 'GRADLE' | |
| android { | |
| buildTypes { | |
| release { | |
| minifyEnabled true | |
| shrinkResources true | |
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | |
| } | |
| } | |
| splits { | |
| abi { | |
| enable true | |
| reset() | |
| include "arm64-v8a", "armeabi-v7a", "x86_64" | |
| universalApk true | |
| } | |
| } | |
| } | |
| GRADLE | |
| - name: Build Release APKs | |
| run: | | |
| cd android | |
| chmod +x gradlew | |
| ./gradlew assembleRelease \ | |
| -Dorg.gradle.jvmargs="-Xmx4g" \ | |
| -Dorg.gradle.parallel=true | |
| - name: Collect and rename APKs | |
| run: | | |
| VERSION="${GITHUB_REF_NAME:-${{ github.event.inputs.release_tag || 'dev' }}}" | |
| mkdir -p apk-output | |
| # Find all release APKs | |
| for apk in $(find android/app/build/outputs/apk/release -name "*.apk"); do | |
| filename=$(basename "$apk") | |
| if echo "$filename" | grep -q "arm64"; then | |
| cp "$apk" "apk-output/FAIRWallet-${VERSION}-arm64.apk" | |
| elif echo "$filename" | grep -q "armeabi"; then | |
| cp "$apk" "apk-output/FAIRWallet-${VERSION}-arm32.apk" | |
| elif echo "$filename" | grep -q "x86_64"; then | |
| cp "$apk" "apk-output/FAIRWallet-${VERSION}-x86_64.apk" | |
| elif echo "$filename" | grep -q "universal"; then | |
| cp "$apk" "apk-output/FAIRWallet-${VERSION}-universal.apk" | |
| else | |
| cp "$apk" "apk-output/FAIRWallet-${VERSION}.apk" | |
| fi | |
| done | |
| echo "=== Built APKs ===" | |
| ls -lh apk-output/ | |
| echo "APK_DIR=apk-output" >> $GITHUB_ENV | |
| - name: Upload APKs as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: FAIRWallet-APKs | |
| path: apk-output/*.apk | |
| retention-days: 90 | |
| - name: Attach APKs to Release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: apk-output/*.apk | |
| - name: Attach APKs to Release (manual trigger) | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.release_tag }} | |
| files: apk-output/*.apk |