Skip to content

Poorgramer-Zack/dart-expert-skills / skills/codemagic

configuring-codemagic

Verified

Configures Codemagic CI/CD pipelines for Flutter using `codemagic.yaml`. Use when setting up automated Flutter builds on Codemagic, configuring iOS code signing without Fastlane Match, deploying to App Store Connect or Google Play from Codemagic, caching pub dependencies in Codemagic, setting up encrypted environment variable groups, running tests with Codemagic's test dashboard, or choosing between Codemagic and GitHub Actions + Fastlane for a Flutter CI/CD pipeline.

Flutter combined with Codemagic Best Practices (YAML approach)

Goal

Implements Codemagic YAML configurations for Flutter deployment. Codemagic natively understands Flutter, requires no extra tooling for code signing, and provides Apple M-series machines for fast iOS compilation.

Instructions

The recommended approach is using codemagic.yaml for "Infrastructure as Code," maintaining it within the project repository alongside the source code.

1. Infrastructure and Cache Strategy

Place codemagic.yaml in the project root. A single file can contain multiple Workflows (e.g., executing iOS deployments and Android deployments separately).

Best Caching Practice: Caching is fundamental to saving CI costs. Be sure to cache Dart dependencies and native build tools.

# 🌟 codemagic.yaml
workflows:
  android-release:
    name: Android Release Workflow
    instance_type: mac_mini_m2 # Apple M2 build machine (verified against Codemagic docs)
    environment:
      # 🌟 Specify the Flutter version
      flutter: stable 
    cache:
      cache_paths:
        - $HOME/.pub-cache # Dart packages
        - $HOME/.gradle/caches # Gradle dependencies

2. Environment Variables & Encrypted Keys

NEVER hardcode Keystore passwords or API Keys in the YAML file. Codemagic provides highly secure UI dashboards to create variable groups, encrypt them, and consume them via scripts.

    environment:
      flutter: stable
      groups:
        # Pre-configured group names on the Codemagic UI
        - keystore_credentials # Contains $KEY_PASSWORD, $ALIAS_PASSWORD
        - google_play_credentials # Contains the JSON key path for the Google Service Account

3. Analyze, Generate & Test

Before building, utilize the scripts block to execute commands sequentially.

    scripts:
      - name: ⬇️ Fetch Dependencies
        script: flutter packages pub get
        
      - name: βš™οΈ Code Generation (build_runner)
        script: dart run build_runner build
        
      - name: 🚨 Static Analysis
        script: flutter analyze
        
      - name: πŸ§ͺ Unit & Widget Tests
        script: |
          mkdir -p test-results
          flutter test --machine > test-results/flutter.json
        # 🌟 Codemagic parses the Flutter --machine JSON and shows the results in the build overview
        test_report: test-results/flutter.json

4. Build Bundle / IPA

Codemagic's greatest strength lies in condensing complex Code Signing flows into extremely minimalist declarative syntax.

4.1 Android Building (with Keystore)

      - name: πŸ”¨ Build Android App Bundle
        script: |
          # Generate a key.properties for android/app/build.gradle to read
          echo "storePassword=$KEYSTORE_PASSWORD" >> android/key.properties
          echo "keyPassword=$KEY_PASSWORD" >> android/key.properties
          echo "keyAlias=$KEY_ALIAS" >> android/key.properties
          echo "storeFile=$KEYSTORE_PATH" >> android/key.properties
          
          # 🌟 The build action
          flutter build appbundle --release

4.2 iOS Code Signing

You typically do not need to manually configure Fastlane Match. Upload your App Store Connect API Key via Codemagic's Web Dashboard, and it automatically handles certificate fetching:

    environment: # Declare before Workflow logic: Enable Auto Signing
      ios_signing:
        distribution_type: app_store
        bundle_identifier: com.yourcompany.app

    scripts:
      - name: 🍏 Build iOS IPA
        script: flutter build ipa --release

5. Push to Store (Publishing)

Once the build concludes, declare the target artifacts, and automatically push directly to the stores utilizing built-in modulesβ€”no upload scripting required!

    artifacts:
      - build/app/outputs/bundle/release/**/*.aab
      - build/ios/ipa/*.ipa

    publishing:
      # Auto-email the team
      email:
        recipients:
          - devteam@company.com
          
      # 🌟 Publish to Google Play (Internal Track)
      google_play:
        credentials: $GCP_SERVICE_ACCOUNT_CREDENTIALS # The JSON key variable
        track: internal
        
      # 🌟 Publish to App Store Connect / TestFlight
      app_store_connect:
        auth: integration # Corresponds to the integrated Apple account from the Dashboard
        submit_to_testflight: true

Constraints

  • Prefer codemagic.yaml over the Codemagic UI workflow editor β€” keeping pipeline configuration in the repository alongside source code is the recommended "Infrastructure as Code" approach.
  • For teams already using Fastlane, Codemagic can still call bundle exec fastlane <lane> from its scripts block; the two tools are not mutually exclusive.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall