ci: upload APK using android_dir output + known Gradle output path, s… #27
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 (Local) | |
| on: | |
| push: | |
| branches: [feature/mobile-app] | |
| paths: | |
| - 'apps/native/**' | |
| - '.github/workflows/build-android-local.yml' | |
| workflow_dispatch: | |
| jobs: | |
| build-android: | |
| name: Expo prebuild → Gradle assembleDebug | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 | |
| env: | |
| EXPO_PUBLIC_CONVEX_URL: https://placeholder.convex.cloud | |
| EXPO_PUBLIC_AUTH_BASE_URL: https://placeholder.convex.site | |
| GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4096m -Dorg.gradle.daemon=false" | |
| EXPO_NO_TELEMETRY: "1" | |
| CI: "true" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Set up Android SDK (clean) | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| packages: > | |
| tools | |
| platform-tools | |
| platforms;android-34 | |
| build-tools;34.0.0 | |
| ndk;26.1.10909125 | |
| cmake;3.22.1 | |
| - uses: actions/setup-node@v4 | |
| with: { node-version: '20' } | |
| - uses: oven-sh/setup-bun@v2 | |
| with: { bun-version: '1.3.5' } | |
| - name: Install native dependencies | |
| working-directory: apps/native | |
| run: bun install --ignore-scripts | |
| - name: Expo prebuild | |
| working-directory: apps/native | |
| continue-on-error: true | |
| run: node_modules/.bin/expo prebuild --platform android --clean --no-install 2>&1 | |
| env: | |
| EXPO_NO_TELEMETRY: "1" | |
| - name: Locate gradlew | |
| id: find-android | |
| run: | | |
| GRADLEW=$(find . -name "gradlew" -not -path "*/node_modules/*" 2>/dev/null | head -1) | |
| [ -n "$GRADLEW" ] || { echo "::error::No gradlew found after prebuild"; exit 1; } | |
| chmod +x "$GRADLEW" | |
| ANDROID_DIR=$(dirname "$GRADLEW") | |
| ANDROID_DIR_ABS=$(realpath "$ANDROID_DIR") | |
| echo "android_dir=$ANDROID_DIR" >> $GITHUB_OUTPUT | |
| echo "android_dir_abs=$ANDROID_DIR_ABS" >> $GITHUB_OUTPUT | |
| echo "apk_dir=$ANDROID_DIR/app/build/outputs/apk/debug" >> $GITHUB_OUTPUT | |
| echo "apk_dir_abs=$ANDROID_DIR_ABS/app/build/outputs/apk/debug" >> $GITHUB_OUTPUT | |
| echo "Found android dir: $ANDROID_DIR_ABS" | |
| - name: Cache Gradle | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/wrapper | |
| ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle-wrapper.properties') }}-v3 | |
| restore-keys: ${{ runner.os }}-gradle- | |
| - name: Build debug APK | |
| working-directory: ${{ steps.find-android.outputs.android_dir }} | |
| run: | | |
| echo "=== Android SDK ===" | |
| echo "ANDROID_HOME=$ANDROID_HOME" | |
| echo "=== Gradle build ===" | |
| ./gradlew assembleDebug --no-daemon --no-build-cache --stacktrace 2>&1 | tee /tmp/gradle.log | tail -80 | |
| # Show what was built and where | |
| - name: Show APK output | |
| run: | | |
| APK_DIR="${{ steps.find-android.outputs.apk_dir_abs }}" | |
| echo "Expected APK dir: $APK_DIR" | |
| ls -lhR "$APK_DIR" 2>/dev/null || echo "(dir not found)" | |
| echo "" | |
| echo "All APK files anywhere:" | |
| find . -name "*.apk" -not -path "*/node_modules/*" 2>/dev/null || echo "(none)" | |
| - name: Upload Gradle log | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-build-log-${{ github.run_number }} | |
| path: /tmp/gradle.log | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| # Upload using the directory path — upload-artifact v4 supports | |
| # uploading an entire directory; it will include all files inside. | |
| - name: Upload debug APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openchat-android-debug-${{ github.run_number }} | |
| path: ${{ steps.find-android.outputs.apk_dir }}/ | |
| if-no-files-found: error | |
| retention-days: 30 | |
| - name: Build summary | |
| if: success() | |
| run: | | |
| echo "### ✅ OpenChat Android Debug APK" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Artifact name:** \`openchat-android-debug-${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**To install on your Pixel 9:**" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Scroll to the Artifacts section at the bottom of this page" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Click the artifact to download a .zip" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Unzip and transfer app-debug.apk to your phone" >> $GITHUB_STEP_SUMMARY | |
| echo "4. Settings → Apps → Special app access → Install unknown apps → Allow" >> $GITHUB_STEP_SUMMARY | |
| echo "5. Open Files app, tap the APK, tap Install" >> $GITHUB_STEP_SUMMARY |