|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - master |
7 | | - pull_request: |
8 | | - types: [closed] |
9 | | - branches: |
10 | | - - master |
| 7 | + - deploy-actions |
11 | 8 | workflow_dispatch: |
12 | 9 |
|
13 | 10 | jobs: |
14 | | - build: |
| 11 | + build_android: |
| 12 | + name: Build Android APK |
15 | 13 | runs-on: ubuntu-latest |
16 | | - |
| 14 | + env: |
| 15 | + JAVA_VERSION: 21.0.6 |
| 16 | + FLUTTER_VERSION: 3.35.2 |
| 17 | + APK_PATH: build/app/outputs/flutter-apk/app-release.apk |
| 18 | + KEYSTORE_PATH: android/upload-keystore.jks |
| 19 | + KEY_PROPS_PATH: android/key.properties |
| 20 | + FIREBASE_OPTIONS_PATH: lib/firebase_options.dart |
| 21 | + GOOGLE_SERVICES_ANDROID_PATH: android/app/google-services.json |
| 22 | + APPWRITE_PROJECT_ID: ${{ secrets.APPWRITE_PROJECT_ID }} |
17 | 23 | steps: |
18 | | - # 1. Remove Cached Flutter Installation |
19 | | - - name: Remove Cached Flutter Installation |
20 | | - run: rm -rf $HOME/.flutter |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
21 | 26 |
|
22 | | - - name: Clean up old build files |
23 | | - run: | |
24 | | - rm -rf build/app/outputs/bundle/release/* |
| 27 | + - name: Setup Java |
| 28 | + uses: actions/setup-java@v4 |
| 29 | + with: |
| 30 | + distribution: zulu |
| 31 | + java-version: ${{ env.JAVA_VERSION }} |
25 | 32 |
|
26 | | - # 2. Checkout repository |
27 | | - - name: Checkout code |
28 | | - uses: actions/checkout@v4 |
| 33 | + - name: Setup Android SDK |
| 34 | + uses: android-actions/setup-android@v3 |
29 | 35 |
|
30 | | - # 3. Install Flutter SDK |
31 | | - - name: Install Flutter |
| 36 | + - name: Setup Flutter |
32 | 37 | uses: subosito/flutter-action@v2 |
33 | 38 | with: |
34 | | - flutter-version: 3.35.2 |
| 39 | + flutter-version: ${{ env.FLUTTER_VERSION }} |
35 | 40 |
|
36 | | - # 4. Verify Flutter and Dart Versions |
37 | | - - name: Verify Flutter Installation |
38 | | - run: | |
39 | | - flutter --version |
40 | | - dart --version |
| 41 | + - name: Decode Android keystore |
| 42 | + run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.KEYSTORE_PATH }} |
41 | 43 |
|
42 | | - # 6. Install Flutter dependencies |
43 | | - - name: Install Flutter Dependencies |
| 44 | + - name: Decode Android key properties |
| 45 | + run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 --decode > ${{ env.KEY_PROPS_PATH }} |
| 46 | + |
| 47 | + - name: Decode Android Google Services JSON |
| 48 | + run: echo "${{ secrets.GOOGLE_SERVICES_ANDROID }}" | base64 --decode > ${{ env.GOOGLE_SERVICES_ANDROID_PATH }} |
| 49 | + |
| 50 | + - name: Decode Firebase Options |
| 51 | + run: echo "${{ secrets.FIREBASE_OPTIONS }}" | base64 --decode > ${{ env.FIREBASE_OPTIONS_PATH }} |
| 52 | + |
| 53 | + - name: Install Flutter dependencies |
44 | 54 | run: flutter pub get |
45 | 55 |
|
46 | | - # 7. Build Android APK |
47 | | - - name: Build Android App Bundle |
48 | | - run: flutter build apk --release --split-per-abi |
| 56 | + - name: Run tests |
| 57 | + run: flutter test |
| 58 | + |
| 59 | + - name: Build Android APK |
| 60 | + run: | |
| 61 | + flutter build apk --release \ |
| 62 | + --dart-define=APPWRITE_BASE_DOMAIN=${{ secrets.APPWRITE_BASE_DOMAIN }} \ |
| 63 | + --dart-define=APPWRITE_PROJECT_ID=${{ secrets.APPWRITE_PROJECT_ID }} |
| 64 | +
|
| 65 | + - name: Verify APK file existence |
| 66 | + run: ls -lh ${{ env.APK_PATH }} |
49 | 67 |
|
50 | | - # 8. Upload build artifacts |
51 | | - - name: Upload APK as an artifact |
| 68 | + - name: Upload APK artifact |
52 | 69 | uses: actions/upload-artifact@v4 |
53 | 70 | with: |
54 | | - name: app-release-apks |
55 | | - path: build/app/outputs/apk/release/*.apk |
| 71 | + name: apk-release |
| 72 | + path: ${{ env.APK_PATH }} |
56 | 73 |
|
57 | | - release: |
| 74 | + deploy_github_release: |
| 75 | + name: Deploy to GitHub Release |
58 | 76 | runs-on: ubuntu-latest |
59 | | - needs: build |
| 77 | + needs: build_android |
60 | 78 | permissions: |
61 | 79 | contents: write |
62 | 80 | steps: |
63 | | - # 1. Checkout repository |
64 | | - - name: Checkout code |
65 | | - uses: actions/checkout@v4 |
66 | | - |
67 | | - # 2. Download build artifacts |
68 | | - - name: Download APK |
| 81 | + - name: Download APK artifact |
69 | 82 | uses: actions/download-artifact@v4 |
70 | 83 | with: |
71 | | - name: app-release-apks |
72 | | - path: build/app/outputs/bundle/release/ |
| 84 | + name: apk-release |
73 | 85 |
|
74 | | - # 3. Upload to Github Release |
75 | | - - name: Github Release |
| 86 | + - name: Deploy to GitHub Release |
76 | 87 | uses: ncipollo/release-action@v1.14.0 |
77 | 88 | with: |
78 | 89 | allowUpdates: true |
79 | | - artifacts: build/app/outputs/bundle/release/*.apk |
| 90 | + artifacts: ${{ env.APK_PATH }} |
80 | 91 | artifactContentType: apk |
81 | 92 | generateReleaseNotes: true |
82 | 93 | tag: latest_build |
0 commit comments