Create main.yml #1
This file contains 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 and Test Flutter App (Android) | |
on: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
build: | |
name: Build APK for Android | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the repository | |
- name: Checkout repository | |
uses: actions/[email protected] | |
# Set up Java 17 | |
- name: Set up Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
# Set up Flutter with a specific version | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.22.2' | |
# Upgrade Gradle to the required version | |
# Clean stale build and cache | |
- name: Clean stale build and cache | |
run: flutter clean | |
# Install Flutter dependencies | |
- name: Install dependencies | |
run: flutter pub get | |
# Build the APK | |
- name: Build APK (Release) | |
run: flutter build apk --release | |
# Upload APK to Firebase App Distribution | |
- name: Upload APK to Firebase App Distribution | |
uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
with: | |
appId: ${{ secrets.FIREBASE_APP_ID }} | |
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }} | |
groups: testers | |
file: build/app/outputs/flutter-apk/app-release.apk | |
# Optionally upload the APK as artifact (for manual download) | |
- name: Upload APK as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release.apk | |
path: build/app/outputs/flutter-apk/app-release.apk |