
Fastlane Flutter + GitLab CI/CD - Release App Senang Gila!
Apa ni?
Hai! Aku tau kau penat upload app kat PlayStore/AppStore. Setiap kali nak release tu, confirm leceh gila!
So, hari ni aku tunjuk cara automate semua tu! Guna Fastlane + GitLab CI/CD. Lepas ni, semua jadi automatik!
Kau Kene Ada
- Flutter project
- GitLab repository (bole guna gitlab.com free)
- Apple Developer Account (kalau nak upload ke AppStore)
- Google Play Console
- Firebase project dengan App Distribution
Step 1: Install Fastlane
Install Fastlane:
cd your-flutter-project
gem install fastlane
Step 2: Initialize
Jalan command ni:
fastlane init
Pilih option:
- iOS untuk AppStore/TestFlight
- Android untuk PlayStore
Step 3: iOS Fastlane
Create ios/fastlane/Fastfile:
default_platform(:ios)
platform :ios do
desc "Beta ke TestFlight"
lane :beta do
increment_build_number
build_app(
scheme: "YourApp",
workspace: "ios/YourApp.xcworkspace",
configuration: "Release"
)
upload_to_testflight
end
desc "Release ke AppStore"
lane :release do
increment_build_number
build_app(
scheme: "YourApp",
workspace: "ios/YourApp.xcworkspace",
configuration: "Release"
)
upload_to_app_store
end
end
Step 4: Android Fastlane
Create android/fastlane/Fastfile:
default_platform(:android)
platform :android do
desc "Staging ke Firebase App Distribution"
lane :staging do
gradle(task: "assembleRelease")
firebase_app_distribution(
app_id: "1:123456789:android:abcdef",
testers: "tester@example.com",
release_notes: "Staging build terbaru!"
)
end
desc "Production ke PlayStore"
lane :production do
gradle(task: "assembleRelease")
upload_to_play_store(
track: "production",
apk: "app/build/outputs/apk/release/app-release.apk"
)
end
end
Step 5: GitLab CI/CD
Create .gitlab-ci.yml:
stages:
- build
- deploy
build_ios:
stage: build
image: macos-13-xcode-14
before_script:
- bundle install
- flutter pub get
script:
- fastlane ios beta
only:
- develop
build_android_staging:
stage: build
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y ruby ruby-dev
- gem install fastlane
- flutter pub get
script:
- fastlane android staging
only:
- develop
build_android_production:
stage: deploy
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y ruby ruby-dev
- gem install fastlane
- flutter pub get
script:
- fastlane android production
only:
- main
Step 6: Secrets
Setup secrets kat GitLab:
- FASTLANE_USER - Apple ID email
- FASTLANE_PASSWORD - Apple ID password
- APP_STORE_CONNECT_API_KEY - API Key from AppStore Connect
- PLAY_STORE_JSON_KEY - Service Account from Google Play
- FIREBASE_TOKEN - Firebase token
Step 7: Push!
Push code kau:
git add .
git commit -m "Add Fastlane CI/CD"
git push origin develop # Staging!
git push origin main # Production!
Settled!
Sekarang:
- Develop branch → Firebase App Distribution (Staging)
- Main branch → PlayStore/AppStore (Production)
Kau sekarang dah separuh pro! Manual upload habis!