|
| 1 | +name: Build and Release Android APK |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' # Triggers on version tags like v1.0.0, v2.1.3, etc. |
| 7 | + |
| 8 | +env: |
| 9 | + EXPO_PUBLIC_FIREBASE_API_KEY: ${{ vars.EXPO_PUBLIC_FIREBASE_API_KEY }} |
| 10 | + EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ vars.EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN }} |
| 11 | + EXPO_PUBLIC_FIREBASE_DATABASE_URL: ${{ vars.EXPO_PUBLIC_FIREBASE_DATABASE_URL }} |
| 12 | + EXPO_PUBLIC_FIREBASE_PROJECT_ID: ${{ vars.EXPO_PUBLIC_FIREBASE_PROJECT_ID }} |
| 13 | + EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ vars.EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET }} |
| 14 | + EXPO_PUBLIC_FIREBASE_APP_ID: ${{ vars.EXPO_PUBLIC_FIREBASE_APP_ID }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-release: |
| 18 | + name: Build Android APK and Create Release |
| 19 | + environment: 'alpha-2' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + submodules: true |
| 30 | + |
| 31 | + - name: Setup pnpm |
| 32 | + uses: pnpm/action-setup@v4 |
| 33 | + |
| 34 | + - name: Setup Node.js |
| 35 | + uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + node-version: '22' |
| 38 | + cache: 'pnpm' |
| 39 | + |
| 40 | + - name: Get pnpm store directory |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + run: pnpm install |
| 47 | + |
| 48 | + - name: Setup JDK 17 |
| 49 | + uses: actions/setup-java@v4 |
| 50 | + with: |
| 51 | + distribution: 'temurin' |
| 52 | + java-version: '17' |
| 53 | + |
| 54 | + - name: Setup Android SDK |
| 55 | + uses: android-actions/setup-android@v3 |
| 56 | + |
| 57 | + - name: Cache Gradle |
| 58 | + uses: actions/cache@v4 |
| 59 | + with: |
| 60 | + path: | |
| 61 | + ~/.gradle/caches |
| 62 | + ~/.gradle/wrapper |
| 63 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 64 | + restore-keys: | |
| 65 | + ${{ runner.os }}-gradle- |
| 66 | +
|
| 67 | + - name: Build Release APK |
| 68 | + run: pnpm build:release |
| 69 | + |
| 70 | + - name: Get release info |
| 71 | + id: release-info |
| 72 | + run: | |
| 73 | + APK_FILE=$(ls generated/app-release-*.apk | head -n 1) |
| 74 | + APK_NAME=$(basename "$APK_FILE") |
| 75 | + TAG_NAME=${GITHUB_REF#refs/tags/} |
| 76 | + FILE_SIZE=$(du -h "$APK_FILE" | cut -f1) |
| 77 | +
|
| 78 | + echo "apk_file=$APK_FILE" >> $GITHUB_OUTPUT |
| 79 | + echo "apk_name=$APK_NAME" >> $GITHUB_OUTPUT |
| 80 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 81 | + echo "file_size=$FILE_SIZE" >> $GITHUB_OUTPUT |
| 82 | +
|
| 83 | + echo "📦 APK: $APK_NAME ($FILE_SIZE)" |
| 84 | +
|
| 85 | + - name: Create Release with gh CLI |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + run: | |
| 90 | + gh release create ${{ steps.release-info.outputs.tag_name }} \ |
| 91 | + --title "MapSwipe Mobile ${{ steps.release-info.outputs.tag_name }}" \ |
| 92 | + --notes "## MapSwipe Mobile ${{ steps.release-info.outputs.tag_name }} |
| 93 | +
|
| 94 | + ### 📱 Download APK |
| 95 | + - **File**: \`${{ steps.release-info.outputs.apk_name }}\` |
| 96 | + - **Size**: ${{ steps.release-info.outputs.file_size }} |
| 97 | +
|
| 98 | + ### 📦 Installation |
| 99 | + 1. Download the APK file below |
| 100 | + 2. Enable \"Install from unknown sources\" in your Android settings |
| 101 | + 3. Open the downloaded APK to install |
| 102 | +
|
| 103 | + ### 🔧 Build Information |
| 104 | + - **Commit**: \`${{ github.sha }}\` |
| 105 | + - **Build**: #${{ github.run_number }} |
| 106 | + - **Date**: $(date +'%Y-%m-%d %H:%M:%S UTC') |
| 107 | +
|
| 108 | + ### ⚙️ Technical Details |
| 109 | + - Built with Expo SDK 54 |
| 110 | + - React Native 0.81.5 |
| 111 | + - Node.js 22" \ |
| 112 | + ${{ steps.release-info.outputs.apk_file }} |
0 commit comments