feat: Configure Codemagic workflows for multi-environment mobile app distribution
This commit is contained in:
136
codemagic.yaml
Normal file
136
codemagic.yaml
Normal file
@@ -0,0 +1,136 @@
|
||||
# codemagic.yaml
|
||||
workflows:
|
||||
# =================================================================================
|
||||
# Base workflow for client_app
|
||||
# =================================================================================
|
||||
client-app-base: &client-app-base
|
||||
name: Client App Base
|
||||
working_directory: mobile-apps/client-app
|
||||
instance_type: mac_mini_m2
|
||||
max_build_duration: 60
|
||||
environment:
|
||||
flutter: stable
|
||||
xcode: latest
|
||||
cocoapods: default
|
||||
cache:
|
||||
cache_paths:
|
||||
- $HOME/.pub-cache
|
||||
- $FCI_BUILD_DIR/mobile-apps/client-app/build
|
||||
- $FCI_BUILD_DIR/mobile-apps/client-app/.dart_tool
|
||||
|
||||
# =================================================================================
|
||||
# Base workflow for staff_app
|
||||
# =================================================================================
|
||||
staff-app-base: &staff-app-base
|
||||
name: Staff App Base
|
||||
working_directory: mobile-apps/staff-app
|
||||
instance_type: mac_mini_m2
|
||||
max_build_duration: 60
|
||||
environment:
|
||||
flutter: stable
|
||||
xcode: latest
|
||||
cocoapods: default
|
||||
cache:
|
||||
cache_paths:
|
||||
- $HOME/.pub-cache
|
||||
- $FCI_BUILD_DIR/mobile-apps/staff-app/build
|
||||
- $FCI_BUILD_DIR/mobile-apps/staff-app/.dart_tool
|
||||
|
||||
# =================================================================================
|
||||
# Client App Workflows
|
||||
# =================================================================================
|
||||
client-app-dev:
|
||||
<<: *client-app-base
|
||||
name: Client App Dev
|
||||
environment:
|
||||
groups:
|
||||
- client_app_dev_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
client-app-staging:
|
||||
<<: *client-app-base
|
||||
name: Client App Staging
|
||||
environment:
|
||||
groups:
|
||||
- client_app_staging_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
client-app-prod:
|
||||
<<: *client-app-base
|
||||
name: Client App Prod
|
||||
environment:
|
||||
groups:
|
||||
- client_app_prod_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
# =================================================================================
|
||||
# Staff App Workflows
|
||||
# =================================================================================
|
||||
staff-app-dev:
|
||||
<<: *staff-app-base
|
||||
name: Staff App Dev
|
||||
environment:
|
||||
groups:
|
||||
- staff_app_dev_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
staff-app-staging:
|
||||
<<: *staff-app-base
|
||||
name: Staff App Staging
|
||||
environment:
|
||||
groups:
|
||||
- staff_app_staging_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
staff-app-prod:
|
||||
<<: *staff-app-base
|
||||
name: Staff App Prod
|
||||
environment:
|
||||
groups:
|
||||
- staff_app_prod_credentials # Codemagic Environment Variable Group
|
||||
scripts:
|
||||
- *build-script
|
||||
- *distribute-script
|
||||
|
||||
# =================================================================================
|
||||
# Reusable Scripts
|
||||
# =================================================================================
|
||||
build-script: &build-script
|
||||
name: Build Flutter App
|
||||
script: |
|
||||
flutter pub get
|
||||
# Uncomment the line below if you use build_runner
|
||||
# flutter pub run build_runner build --delete-conflicting-outputs
|
||||
|
||||
# Build Android
|
||||
flutter build appbundle --flavor $FLAVOR
|
||||
|
||||
# Build iOS
|
||||
flutter build ipa --flavor $FLAVOR --export-options-plist=$FCI_BUILD_DIR/mobile-apps/client-app/ios/exportOptions.plist
|
||||
|
||||
distribute-script: &distribute-script
|
||||
name: Distribute to Firebase App Distribution
|
||||
script: |
|
||||
# Distribute Android
|
||||
firebase appdistribution:distribute "build/app/outputs/bundle/${FLAVOR}-release/app-${FLAVOR}-release.aab" \
|
||||
--app $FIREBASE_APP_ID_ANDROID \
|
||||
--release-notes "Build $FCI_BUILD_NUMBER" \
|
||||
--groups "$FIREBASE_TESTER_GROUPS" \
|
||||
--token $FIREBASE_TOKEN
|
||||
|
||||
# Distribute iOS
|
||||
firebase appdistribution:distribute "build/ios/ipa/app.ipa" \
|
||||
--app $FIREBASE_APP_ID_IOS \
|
||||
--release-notes "Build $FCI_BUILD_NUMBER" \
|
||||
--groups "$FIREBASE_TESTER_GROUPS" \
|
||||
--token $FIREBASE_TOKEN
|
||||
34
docs/prompts/create-codemagic-monorepo.md
Normal file
34
docs/prompts/create-codemagic-monorepo.md
Normal file
@@ -0,0 +1,34 @@
|
||||
Looking at the monorepo containing two separate Flutter applications in
|
||||
- mobile-apps/client-app
|
||||
- mobile-apps/staff-app
|
||||
, and I want to configure Codemagic so both apps can be built and distributed to Firebase App Distribution.
|
||||
|
||||
Please do the following:
|
||||
1. propose the best layout for Codemagic workflows.
|
||||
2. Create three separate pipelines for each application:
|
||||
* Development (dev)
|
||||
* Staging (stage)
|
||||
* Production (prod)
|
||||
3. Each pipeline must:
|
||||
* Build the correct Flutter app inside the monorepo.
|
||||
* Use the correct Firebase App Distribution credentials for each environment.
|
||||
* Push the built artifacts (Android + iOS if applicable) to the appropriate Firebase App Distribution app.
|
||||
* Include environment-specific values (e.g., env variables, bundle IDs, keystore/certs, build flavors).
|
||||
* Allow triggering pipelines manually.
|
||||
4. Generate a complete codemagic.yaml example with:
|
||||
* Separate workflows for:
|
||||
* `client_app_dev`, `client_app_staging`, `client_app_prod`
|
||||
* `client_app_dev`, `client_app_staging`, `client_app_prod`
|
||||
* All required steps (install Flutter/Java/Xcode, pub get, build runner if needed, building APK/AAB/IPA, uploading to Firebase App Distribution, etc.).
|
||||
* Example Firebase App IDs, release notes, tester groups, service accounts.
|
||||
* Proper use of Codemagic encrypted variables.
|
||||
* Best practices for monorepo path handling.
|
||||
5. Add a short explanation of:
|
||||
* How each pipeline works
|
||||
* How to trigger builds
|
||||
* How to update environment variables for Firebase
|
||||
6. Output the final result as:
|
||||
* A complete `codemagic.yaml`
|
||||
* A brief guide on integrating it with a monorepo
|
||||
* Notes on debugging, caching, and CI/CD optimization
|
||||
|
||||
Reference in New Issue
Block a user