Skip to content
Latchkey

CI/CD for a Flutter Web + Mobile App with GitHub Actions

Analyze, test, and build web and Android from one Flutter codebase.

A single Flutter codebase can build for web and mobile. This recipe analyzes and tests once, then builds the web bundle and the Android APK in a matrix and publishes each output.

What the pipeline does

  • set up Flutter
  • analyze with flutter analyze
  • test with flutter test
  • build web and Android targets via a matrix
  • publish the web build and upload the APK

The workflow

flutter build web emits build/web; flutter build apk emits the Android package. A matrix runs both targets after a shared analyze/test job.

.github/workflows/ci.yml
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [web, apk]
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
        with:
          channel: stable
          cache: true
      - run: flutter pub get
      - run: flutter analyze
      - run: flutter test
      - run: flutter build ${{ matrix.target }} --release
      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: build

Caching and speed

flutter-action with cache: true caches the SDK, and the pub cache plus Gradle cache speed the Android leg. The Android build is the heavier target; cheaper managed runners such as Latchkey (around 70% cheaper than GitHub-hosted) keep these matrix builds affordable and auto-retry transient pub or Gradle download failures.

Deploying

Deploy build/web to Pages, Firebase Hosting, or S3+CloudFront. Sign the APK/AAB and upload to the Play Console (manually or via a publisher action). iOS builds need a macOS runner with Xcode and signing.

Key takeaways

  • One codebase builds web and mobile via a matrix.
  • cache: true on flutter-action caches the SDK across legs.
  • iOS builds require a macOS runner; web and Android run on Linux.

Frequently asked questions

CI/CD for a Flutter Web + Mobile App with GitHub Actions?
A single Flutter codebase can build for web and mobile. This recipe analyzes and tests once, then builds the web bundle and the Android APK in a matrix and publishes each output.
The workflow?
flutter build web emits build/web; flutter build apk emits the Android package. A matrix runs both targets after a shared analyze/test job.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card