From 68407e3b47879965a8c79f89d9dc6cddbc1989df Mon Sep 17 00:00:00 2001 From: Moe Hamade <69801237+moehamade@users.noreply.github.com> Date: Mon, 5 Jan 2026 12:28:53 +0200 Subject: [PATCH] feat: Build and release per-architecture APKs (#550) * feat: Build and release per-architecture APKs This commit modifies the build process to generate separate APKs for different CPU architectures (arm64-v8a, x86_64) and a universal APK. This allows for smaller, optimized downloads for users and provides specific builds for platforms like Chromebooks. Key changes: - In `app/build.gradle.kts`, enables ABI splits to create `arm64-v8a`, `x86_64`, and `universal` APKs during the `assembleRelease` task. - Updates the `release.yml` GitHub Actions workflow to rename and upload each of these APKs as distinct release assets. - Removes the previous `arm64-v8a` only filter to allow for multi-architecture builds. * feat: Allow manual triggering of Android CI workflow This adds the `workflow_dispatch` event to the `android-build.yml` GitHub Actions workflow. This change enables the Android CI pipeline to be run manually from the GitHub UI, in addition to the existing triggers for pushes and pull requests. --- .github/workflows/android-build.yml | 1 + .github/workflows/release.yml | 37 +++++++++++++++-------------- app/build.gradle.kts | 17 +++++++++---- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 2f8a7906..9911c273 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -1,6 +1,7 @@ name: Android CI on: + workflow_dispatch: push: branches: [ "main", "develop" ] pull_request: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79495ee9..f1e1841a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,17 +38,20 @@ jobs: - name: Grant execute permission for Gradlew run: chmod +x ./gradlew - - name: Build Release APK (with Tor) + - name: Build Release APKs (with architecture splits) run: ./gradlew assembleRelease --no-daemon --stacktrace - name: List APK files run: | echo "APK files built:" - find app/build/outputs/apk -name "*.apk" -type f + find app/build/outputs/apk/release -name "*.apk" -type f -exec ls -lh {} \; - - name: Rename APK + - name: Rename APKs for GitHub Release run: | - mv app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/bitchat-android.apk + cd app/build/outputs/apk/release + [ -f "app-arm64-v8a-release-unsigned.apk" ] && mv app-arm64-v8a-release-unsigned.apk bitchat-android-arm64.apk + [ -f "app-x86_64-release-unsigned.apk" ] && mv app-x86_64-release-unsigned.apk bitchat-android-x86_64.apk + [ -f "app-universal-release-unsigned.apk" ] && mv app-universal-release-unsigned.apk bitchat-android-universal.apk - name: DEBUG run: | @@ -59,8 +62,8 @@ jobs: ls -all tree || ls -R - # Optional: Sign APK (requires secrets) - # - name: Sign APK + # Optional: Sign APKs (uncomment and configure secrets when ready) + # - name: Sign APKs # uses: r0adkll/sign-android-release@v1 # with: # releaseDirectory: app/build/outputs/apk/release @@ -69,10 +72,10 @@ jobs: # keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} # keyPassword: ${{ secrets.KEY_PASSWORD }} - - name: Upload APK as artifact + - name: Upload APKs as artifacts uses: actions/upload-artifact@v4 with: - name: bitchat-android-apk-${{ github.ref_name }} + name: bitchat-android-release-${{ github.ref_name }} path: app/build/outputs/apk/release/*.apk retention-days: 30 if-no-files-found: error @@ -82,25 +85,23 @@ jobs: runs-on: ubuntu-latest steps: - - name: Download APK artifact + - name: Download release artifacts uses: actions/download-artifact@v4 with: - name: bitchat-android-apk-${{ github.ref_name }} + name: bitchat-android-release-${{ github.ref_name }} path: release - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: files: | - release/bitchat-android.apk + release/bitchat-android-arm64.apk + release/bitchat-android-x86_64.apk + release/bitchat-android-universal.apk name: Release ${{ github.ref_name }} body: | - ## bitchat Android Release - - **bitchat-android.apk** (~15MB) - - Secure P2P messaging over Bluetooth mesh and Nostr - - Built-in Tor support (custom Arti build with 16KB page size) - - Compatible with Google Play requirements (Nov 2025+) - - Cross-platform compatible with iOS version + **bitchat-android-arm64.apk** - ARM64 (most phones) + **bitchat-android-x86_64.apk** - x86_64 (Chromebooks, tablets) + **bitchat-android-universal.apk** - All architectures (fallback) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6605a757..a9511725 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -43,13 +43,20 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) - ndk { - // ARM64-only to minimize APK size (~5.8MB savings) - // Excludes x86_64 as emulator not needed for production builds - abiFilters += listOf("arm64-v8a") - } } } + + // APK splits for GitHub releases - creates arm64, x86_64, and universal APKs + // AAB for Play Store handles architecture distribution automatically + splits { + abi { + isEnable = true + reset() + include("arm64-v8a", "x86_64") + isUniversalApk = true // For F-Droid and fallback + } + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8