Merge pull request #37 from jingle-jew/dev #2
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: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - ".github/workflows/build-android-apk.yml" | |
| - "android-app/**" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-android-apk: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: android-app | |
| env: | |
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
| ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | |
| ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
| ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/android-app/android/release-keystore.jks | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| cache-dependency-path: android-app/package-lock.json | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install Android wrapper dependencies | |
| run: npm ci | |
| - name: Decode release keystore | |
| if: ${{ env.ANDROID_KEYSTORE_BASE64 != '' }} | |
| shell: bash | |
| run: | | |
| echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH" | |
| - name: Sync Capacitor assets | |
| run: npm run sync | |
| - name: Make Gradle wrapper executable | |
| run: chmod +x android/gradlew | |
| - name: Build release APK | |
| run: ./android/gradlew assembleRelease | |
| - name: Upload signed release APK | |
| if: ${{ env.ANDROID_KEYSTORE_BASE64 != '' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mha-widget-hub-apk | |
| path: android-app/android/app/build/outputs/apk/release/app-release.apk | |
| if-no-files-found: error | |
| - name: Upload unsigned release APK | |
| if: ${{ env.ANDROID_KEYSTORE_BASE64 == '' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mha-widget-hub-apk | |
| path: android-app/android/app/build/outputs/apk/release/app-release-unsigned.apk | |
| if-no-files-found: error | |
| - name: Remove temporary keystore | |
| if: ${{ always() && env.ANDROID_KEYSTORE_BASE64 != '' }} | |
| shell: bash | |
| run: rm -f "$ANDROID_KEYSTORE_PATH" |