Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 63 additions & 53 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,90 @@ name: Build and Deploy
on:
push:
branches:
- main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resonate has a master branch, not main

- master
pull_request:
types: [closed]
branches:
- master
workflow_dispatch:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep workflow_dispatch so that we can trigger the workflow manually

- deploy-actions

jobs:
build:
github_release_android:
name: Android GitHub Release
runs-on: ubuntu-latest

# Add permissions for the release action to write to contents
permissions:
contents: write
env:
JAVA_VERSION: 17
FLUTTER_VERSION: 3.35.2
AAB_PATH: build/app/outputs/bundle/release/app-release.aab
KEYSTORE_PATH: upload-keystore.jks
KEY_PROPS_PATH: key.properties
FIREBASE_OPTIONS_PATH: lib/firebase_options.dart
GOOGLE_SERVICES_ANDROID_PATH: android/app/google-services.json
APPWRITE_PROJECT_ID: ${{ secrets.APPWRITE_PROJECT_ID }}
steps:
# 1. Remove Cached Flutter Installation
- name: Remove Cached Flutter Installation
run: rm -rf $HOME/.flutter
- name: Checkout repository
uses: actions/checkout@v4

- name: Clean up old build files
run: |
rm -rf build/app/outputs/bundle/release/*
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ env.JAVA_VERSION }}

# 2. Checkout repository
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Android SDK
uses: android-actions/setup-android@v3

# 3. Install Flutter SDK
- name: Install Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.35.2
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true

# 4. Verify Flutter and Dart Versions
- name: Verify Flutter Installation
run: |
flutter --version
dart --version
# --- Decode All Secrets ---
# These are required for the release build to sign the app
- name: Decode Android keystore
run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.KEYSTORE_PATH }}

- name: Decode Android key properties
run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 --decode > ${{ env.KEY_PROPS_PATH }}

# 6. Install Flutter dependencies
- name: Install Flutter Dependencies
# These are required for Firebase/Google Services
- name: Decode Android Google Services JSON
run: echo "${{ secrets.GOOGLE_SERVICES_ANDROID }}" | base64 --decode > ${{ env.GOOGLE_SERVICES_ANDROID_PATH }}

- name: Decode Firebase Options
run: echo "${{ secrets.FIREBASE_OPTIONS }}" | base64 --decode > ${{ env.FIREBASE_OPTIONS_PATH }}
# --- End of Decode Steps ---

- name: Install Flutter dependencies
run: flutter pub get

# 7. Build Android APK
- name: Build Android App Bundle
run: flutter build apk --release --split-per-abi
- name: Run tests
run: flutter test

# 8. Upload build artifacts
- name: Upload APK as an artifact
uses: actions/upload-artifact@v4
with:
name: app-release-apks
path: build/app/outputs/apk/release/*.apk
# This build command is now correct
- name: Build Android App Bundle (AAB)
run: |
flutter build appbundle --release \
--dart-define=APPWRITE_BASE_DOMAIN=${{ secrets.APPWRITE_BASE_DOMAIN }} \
--dart-define=APPWRITE_PROJECT_ID=${{ secrets.APPWRITE_PROJECT_ID }}

release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
# 1. Checkout repository
- name: Checkout code
uses: actions/checkout@v4
# Debugging step to verify AAB file existence
- name: Verify AAB file existence
run: ls -lh ${{ env.AAB_PATH }} || true

# 2. Download build artifacts
- name: Download APK
uses: actions/download-artifact@v4
- name: Upload AAB artifact
uses: actions/upload-artifact@v4
with:
name: app-release-apks
path: build/app/outputs/bundle/release/
name: aab-release
path: ${{ env.AAB_PATH }}

# 3. Upload to Github Release
- name: Github Release
- name: Deploy to GitHub Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifacts: build/app/outputs/bundle/release/*.apk
artifactContentType: apk
artifacts: ${{ env.AAB_PATH }}
artifactContentType: aab
generateReleaseNotes: true
tag: latest_build
token: ${{ secrets.GITHUB_TOKEN }}