Below is a clear, practical guide to using CI/CD in Flutter, with real-world examples that work for Android, iOS, and web apps.
What is CI/CD in Flutter?
CI (Continuous Integration) automatically:
- Fetches your Flutter code
- Installs dependencies
- Runs tests & static analysis
- Builds the app
CD (Continuous Deployment) automatically:
- Generates APK/AAB/IPA/Web builds
- Uploads builds to Play Store / TestFlight / Firebase / servers
Popular CI/CD Tools for Flutter
| Tool | Best For |
|---|---|
| GitHub Actions | Free, easy, most popular |
| GitLab CI | Enterprise projects |
| Bitrise | Mobile-focused CI/CD |
| Codemagic | Flutter-first CI/CD |
| Jenkins | Self-hosted CI/CD |
👉 Recommended: GitHub Actions (free & flexible)
Basic Flutter CI/CD Flow
- Push code to GitHub
- CI runs automatically
- Flutter checks & builds
- Artifacts are generated
- CD uploads build
Step 1: Prepare Flutter Project
Make sure your project works locally:
flutter doctor
flutter test
flutter build apk
Step 2: GitHub Actions Setup
Create this file:
📁 .github/workflows/flutter_ci.yml
name: Flutter CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: 'stable'
- name: Install dependencies
run: flutter pub get
- name: Analyze code
run: flutter analyze
- name: Run tests
run: flutter test
- name: Build APK
run: flutter build apk
✅ Automatically runs on every push
Step 3: Generate Release Builds
Android AAB (Play Store)
- name: Build App Bundle
run: flutter build appbundle
Web
- name: Build Web
run: flutter build web
Step 4: Upload Build Artifacts
- uses: actions/upload-artifact@v4
with:
name: flutter-build
path: build/
Step 5: Android Signing (Important)
- Create keystore
keytool -genkey -v -keystore keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
- Add secrets in GitHub:
KEYSTORE_BASE64KEYSTORE_PASSWORDKEY_ALIASKEY_PASSWORD
- Decode keystore in CI:
- name: Decode keystore
run: |
echo "$KEYSTORE_BASE64" | base64 --decode > android/app/keystore.jks
Step 6: Firebase App Distribution (Optional)
- name: Upload to Firebase
run: |
npm install -g firebase-tools
firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk \
--app $FIREBASE_APP_ID \
--token $FIREBASE_TOKEN
Step 7: iOS CI/CD (Mac Required)
runs-on: macos-latest
Build:
flutter build ipa
⚠️ Requires:
- Apple Developer account
- Certificates & provisioning profiles
Best Practices for Flutter CI/CD
✔ Use separate workflows for dev & prod
✔ Run flutter analyze + test before build
✔ Never commit keystore or credentials
✔ Use environment-based builds
✔ Cache Flutter packages for faster builds
Recommended CI/CD for Flutter (Beginner → Pro)
- Beginner: GitHub Actions
- Intermediate: Codemagic
- Enterprise: Bitrise + Fastlane
Flutter CI/CD Architecture Diagram
Git Push → CI (Tests) → Build → Artifact → Store / Firebase
