Last updated: November 13, 2026

Bahasa Indonesia | English

Repeated manual checks are easy to miss and difficult to reproduce. In this codelab, you will set up a CI/CD pipeline that consistently runs Flutter checks, tests, and builds with GitHub Actions.

Learning objectives

What you need

1. CI and CD

Continuous integration (CI) runs automated checks when changes are proposed or pushed. Continuous delivery/deployment (CD) automates release preparation or delivery. A good pipeline makes important steps repeatable and its results reviewable.

  1. A commit or pull request triggers the workflow.
  2. A runner checks out the source and sets up Flutter.
  3. Formatting, static analysis, and tests run.
  4. If checks pass, the app is built and its artifacts are stored.

2. Events and permissions

Use pull_request to check changes before merging and push to check the main branch. Grant only the minimum permissions required. Pull requests from forks do not receive repository GitHub Secrets.

1. Add the workflow file

At the project root, create .github/workflows/flutter-ci.yml. Change the branch name if your default branch is not main.

name: Flutter CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test-and-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
        with:
          channel: stable
      - run: flutter pub get
      - run: dart format --output=none --set-exit-if-changed .
      - run: flutter analyze --fatal-infos
      - run: flutter test --coverage

2. Check locally

Before pushing, run the same formatting, analysis, and test commands on your project. Fix failures; do not remove checks just to make the workflow green.

1. Add build steps

After the tests pass, add these steps to the same job:

      - run: flutter build apk --release
      - run: flutter build appbundle --release
      - uses: actions/upload-artifact@v4
        with:
          name: android-builds
          path: |
            build/app/outputs/flutter-apk/app-release.apk
            build/app/outputs/bundle/release/app-release.aab
          if-no-files-found: error
          retention-days: 7

1. Versioning

In pubspec.yaml, a version such as 1.2.0+15 means app version 1.2.0 and build number 15. Follow semantic versioning: major for incompatible changes, minor for compatible features, and patch for fixes. Increment the build number for each new upload.

Use a tag such as v1.2.0 to connect source, pipeline logs, and artifacts. Make sure the tag points to a commit that passed the checks.

2. Secrets and configuration

For signed releases, follow Flutter's official signing guide and inject sensitive material only into a restricted release workflow. Do not expose a production keystore to pull-request workflows.

1. Run the workflow

  1. Commit the workflow file and push it to GitHub.
  2. Open the Actions tab and select the relevant run.
  3. Review each step. Confirm that a test failure makes the job fail.
  4. Download the artifact and record the commit that produced it.

2. Assignment

  1. Add a CI workflow to your Flutter project with formatting, analysis, and tests.
  2. Build an APK and AAB and store both as artifacts.
  3. Run the workflow on a pull request or push to the main branch; include evidence of the result and commit.
  4. Document the next version, checks performed, and any security risks that remain.

Reflection

Supporting references