Why I Decided to Automate My Flutter Builds

Every time I completed a feature, I had to:

  1. Build an APK or IPA manually
  2. Test it locally
  3. Zip and upload it to TestFlight or share it with QA

It was tedious and error-prone.

By using GitHub Actions, I now trigger builds automatically on every push or pull request, and the generated artifacts are ready for testing. It’s also incredibly useful for CI/CD pipelines when releasing to the Play Store or App Store.


Step 1: Creating My Flutter Project on GitHub

I already had my Flutter app locally. So, I initialized the Git repo:

 git init
 git remote add origin https://github.com/myusername/myflutterapp.git
 git add .
 git commit -m "Initial commit"
 git push -u origin main

Then came the magic: setting up GitHub Actions.


Step 2: Setting Up the GitHub Actions Workflow

In the root of my Flutter project, I created a folder called .github/workflows. Inside it, I added a file:

 mkdir -p .github/workflows
 touch .github/workflows/flutter_build.yml

This file will define the GitHub Action workflow.


Step 3: Writing the flutterbuild.yml Workflow

Here’s my initial flutterbuild.yml file:

 name: Flutter CI
 on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
 jobs:
  build:
    runs-on: ubuntu-latest
 
    steps:
      - name: Checkout source
        uses: actions/checkout@v3
 
      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: ’3.22.0’ # Replace with your Flutter version
 
      - name: Install dependencies
        run: flutter pub get
      - name: Analyze code
        run: flutter analyze
 
      - name: Run tests
        run: flutter test
 
      - name: Build APK
        run: flutter build apk --release
 
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: release-apk
          path: build/app/outputs/flutter-apk/app-release.apk


Let Me Break It Down Step by Step

on: Section

This tells GitHub when to run the workflow. I set it to trigger on every push or pull request to the main branch.

jobs: and build:

This defines the job. I named it build and specified ubuntu-latest as the environment, which is perfect for building Flutter apps.

Step: Checkout source

  - name: Checkout source
  uses: actions/checkout@v3

This checks out my code from the GitHub repository so that the runner can access it.

Step: Set up Flutter

  - name: Set up Flutter
  uses: subosito/flutter-action@v2
  with:
    flutter-version: ’3.22.0’

This installs Flutter in the GitHub runner. I use the exact version that matches my local dev environment.

Step: Install dependencies

  - name: Install dependencies
  run: flutter pub get

This step installs all the Dart/Flutter dependencies from pubspec.yaml.

Step: Analyze code

  - name: Analyze code
  run: flutter analyze

It’s always good practice to run static analysis to catch potential issues early.

Step: Run tests

  - name: Run tests
  run: flutter test

This runs all my unit tests to ensure everything still works.

Step: Build APK

  - name: Build APK
  run: flutter build apk --release

This builds the release version of the APK, which is what I usually send to testers.

Step: Upload artifact

  - name: Upload artifact
  uses: actions/upload-artifact@v4
  with:
    name: release-apk
    path: build/app/outputs/flutter-apk/app-release.apk

This uploads the APK to the “Artifacts” section of the GitHub Actions page so I (or my QA team) can download it


Step 4: Pushing Changes and Watching It Work

Once I pushed the .github/workflows/flutter_build.yml file to the repository:

 git add .
 git commit -m "Add GitHub Actions workflow"
 git push

 

GitHub Actions automatically kicked in. I visited the Actions tab in my repository and saw the workflow run in real-time 🎉

At the end of the build, I could download the APK from the job summary. No more manual builds for every change!


Step 5: Improving the Workflow for iOS (Optional)

For iOS, it’s a bit tricky since Apple builds require macOS. If you want to build .ipa files, you’ll need a macOS runner, which GitHub supports — but on a limited basis (and slower than Ubuntu).

Here’s a simplified snippet for building iOS:

  jobs:
  build_ios:
    runs-on: macos-latest
    steps:
      - name: Checkout source
        uses: actions/checkout@v3
 
      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: ’3.22.0’
 
      - name: Install dependencies
        run: flutter pub get
 
      - name: Build iOS
        run: flutter build ios --no-codesign

I used --no-codesign because signing iOS apps requires credentials and certificates, which I didn’t want to set up just yet. But it’s a good start for CI.


Step 6: Bonus – Notify Me on Slack/Discord

I added notifications to alert my team when builds fail or succeed using a Slack webhook:

  - name: Notify Slack
  uses: rtCamp/action-slack-notify@v2
  env:
    SLACKWEBHOOK: ${{ secrets.SLACKWEBHOOK }}
    SLACK_MESSAGE: Build ${{ job.status }} for ${{ github.repository }}

 

I stored my Slack webhook URL securely in GitHub Secrets.


Final Thoughts

Setting up GitHub Actions was one of the most empowering decisions I’ve made for my Flutter projects. Now:

●    Every push gets analyzed, tested, and built automatically



●    My QA team can easily access the APKs



●    I save time, reduce mistakes, and focus on building features



If you’re a Flutter dev and not using GitHub Actions yet — start today. It’s simple, powerful, and you only have to set it up once.

 

 

Our Trusted
Partner.

Unlock Valuable Cloud and Technology Credits

Imagine reducing your operational costs by up to $100,000 annually without compromising on the technology you rely on. Through our partnerships with leading cloud and technology providers like AWS (Amazon Web Services), Google Cloud Platform (GCP), Microsoft Azure, and Nvidia Inception, we can help you secure up to $25,000 in credits over two years (subject to approval).

These credits can cover essential server fees and offer additional perks, such as:

  • Google Workspace accounts
  • Microsoft accounts
  • Stripe processing fee waivers up to $25,000
  • And many other valuable benefits

Why Choose Our Partnership?

By leveraging these credits, you can significantly optimize your operational expenses. Whether you're a startup or a growing business, the savings from these partnerships ranging from $5,000 to $100,000 annually can make a huge difference in scaling your business efficiently.

The approval process requires company registration and meeting specific requirements, but we provide full support to guide you through every step. Start saving on your cloud infrastructure today and unlock the full potential of your business.

exclusive-partnersexclusive-partners

Let's TALK

Let's TALK and bring your ideas to life! Our experienced team is dedicated to helping your business grow and thrive. Reach out today for personalized support or request your free quote to kickstart your journey to success.

DIGITAL PRODUCTUI/UX DESIGNDIGITAL STUDIOBRANDING DESIGNUI/UX DESIGNEMAIL MARKETINGBRANDING DESIGNUI/UX DESIGNEMAIL MARKETING
DIGITAL PRODUCTUI/UX DESIGNDIGITAL STUDIOBRANDING DESIGNUI/UX DESIGNEMAIL MARKETINGBRANDING DESIGNUI/UX DESIGNEMAIL MARKETING