feat: Android app with Capacitor and CI build #6
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: | |
| push: | |
| branches: [feature/androidapp, master] | |
| tags: ['v*'] | |
| paths: | |
| - 'src/**' | |
| - 'APK/**' | |
| - 'package.json' | |
| - 'vite.config.ts' | |
| - '.github/workflows/build-apk.yml' | |
| pull_request: | |
| branches: [master] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install root dependencies | |
| run: npm ci | |
| - name: Install APK dependencies | |
| working-directory: APK | |
| run: npm ci | |
| - name: Build web assets and sync Capacitor | |
| working-directory: APK | |
| run: npm run build | |
| - name: Build debug APK | |
| working-directory: APK/android | |
| run: chmod +x gradlew && ./gradlew assembleDebug | |
| - name: Rename APK with version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| cp APK/android/app/build/outputs/apk/debug/app-debug.apk \ | |
| APK/android/app/build/outputs/apk/debug/communauto-tools-${VERSION}.apk | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: communauto-tools-debug | |
| path: APK/android/app/build/outputs/apk/debug/app-debug.apk | |
| retention-days: 30 | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: APK/android/app/build/outputs/apk/debug/communauto-tools-*.apk | |
| generate_release_notes: true |