Skip to content

Commit bad329b

Browse files
authored
Merge pull request #581 from uju09/fix/build_n_deploy_workflow
fix(ci) : Build and deploy workflow
2 parents 54fb08d + cee89b6 commit bad329b

1 file changed

Lines changed: 56 additions & 45 deletions

File tree

.github/workflows/build_and_deploy.yml

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,90 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
8-
types: [closed]
9-
branches:
10-
- master
7+
- deploy-actions
118
workflow_dispatch:
129

1310
jobs:
14-
build:
11+
build_android:
12+
name: Build Android APK
1513
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 }}
1723
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
2126

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 }}
2532

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
2935

30-
# 3. Install Flutter SDK
31-
- name: Install Flutter
36+
- name: Setup Flutter
3237
uses: subosito/flutter-action@v2
3338
with:
34-
flutter-version: 3.35.2
39+
flutter-version: ${{ env.FLUTTER_VERSION }}
3540

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 }}
4143

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
4454
run: flutter pub get
4555

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 }}
4967

50-
# 8. Upload build artifacts
51-
- name: Upload APK as an artifact
68+
- name: Upload APK artifact
5269
uses: actions/upload-artifact@v4
5370
with:
54-
name: app-release-apks
55-
path: build/app/outputs/apk/release/*.apk
71+
name: apk-release
72+
path: ${{ env.APK_PATH }}
5673

57-
release:
74+
deploy_github_release:
75+
name: Deploy to GitHub Release
5876
runs-on: ubuntu-latest
59-
needs: build
77+
needs: build_android
6078
permissions:
6179
contents: write
6280
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
6982
uses: actions/download-artifact@v4
7083
with:
71-
name: app-release-apks
72-
path: build/app/outputs/bundle/release/
84+
name: apk-release
7385

74-
# 3. Upload to Github Release
75-
- name: Github Release
86+
- name: Deploy to GitHub Release
7687
uses: ncipollo/release-action@v1.14.0
7788
with:
7889
allowUpdates: true
79-
artifacts: build/app/outputs/bundle/release/*.apk
90+
artifacts: ${{ env.APK_PATH }}
8091
artifactContentType: apk
8192
generateReleaseNotes: true
8293
tag: latest_build

0 commit comments

Comments
 (0)