|
| 1 | +name: Android Release APK |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: "Tag to release (e.g., v1.0.0)" |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-release: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + CI: true |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Use Node.js 20 |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: "20" |
| 30 | + cache: "npm" |
| 31 | + |
| 32 | + - name: Install JS dependencies |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: Set up JDK 17 |
| 36 | + uses: actions/setup-java@v4 |
| 37 | + with: |
| 38 | + distribution: "temurin" |
| 39 | + java-version: "17" |
| 40 | + cache: "gradle" |
| 41 | + |
| 42 | + - name: Set up Android SDK |
| 43 | + uses: android-actions/setup-android@v3 |
| 44 | + |
| 45 | + - name: Accept Android SDK licenses |
| 46 | + run: yes | sdkmanager --licenses |
| 47 | + |
| 48 | + - name: Install Android SDK components |
| 49 | + run: | |
| 50 | + sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" "ndk;26.1.10909125" "cmake;3.22.1" |
| 51 | +
|
| 52 | + - name: Point local.properties to CI Android SDK |
| 53 | + run: echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties |
| 54 | + |
| 55 | + - name: Ensure Gradle wrapper is executable |
| 56 | + run: chmod +x android/gradlew |
| 57 | + |
| 58 | + - name: Setup Gradle caching |
| 59 | + uses: gradle/actions/setup-gradle@v3 |
| 60 | + |
| 61 | + - name: Build release APK |
| 62 | + working-directory: android |
| 63 | + run: ./gradlew :app:assembleRelease --stacktrace --no-daemon |
| 64 | + |
| 65 | + - name: Upload APK artifact |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: app-release-apk |
| 69 | + path: android/app/build/outputs/apk/release/*.apk |
| 70 | + |
| 71 | + - name: Create GitHub Release |
| 72 | + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' |
| 73 | + uses: softprops/action-gh-release@v2 |
| 74 | + with: |
| 75 | + tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} |
| 76 | + name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} |
| 77 | + files: | |
| 78 | + android/app/build/outputs/apk/release/*.apk |
| 79 | + generate_release_notes: true |
0 commit comments