This article explains how to create Flutter application template with GitHub Actions to save yourself time and nerves.

Getting started

  1. Sample application used in this tutorial Flutter CI Test
  2. Create flutter application
  3. You can use flutter_flavorizr to generate Android/iOS flavors. Sample configuration with firebase support can be found in pubspec.yaml

Create Firebase project

  1. Here you can create Firebase project. Make sure that project belongs to your organization.
  2. Create Firebase apps (one per flavor and platform e.g. Android dev, iOS dev, Android staging, iOS staging etc.) in Firebase overview https://console.firebase.google.com/project/{project_name}/overview.
    Follow steps in creator to download config files and add Firebase SDK to flutter app. More details here
  3. Create “alpha-testers” and “beta-testers” groups in Firebase App Distribution.

Google Play Console

  1. Create application in Google Play Console Make sure that project belongs to your organization.
  2. Generate debug and upload key
  3. Update signingConfigs and buildTypes in android/app/build.gradle.
signingConfigs {
        release {
            storeFile file("upload-key.jks")
            keyAlias System.getenv("KEYSTORE_KEY_ALIAS") ?: localProperties.getProperty("KEYSTORE_KEY_ALIAS")
            keyPassword System.getenv("KEYSTORE_KEY_PASSWORD") ?: localProperties.getProperty("KEYSTORE_KEY_PASSWORD")
            storePassword System.getenv("KEYSTORE_STORE_PASSWORD") ?: localProperties.getProperty("KEYSTORE_STORE_PASSWORD")
        }
        debug {
            storeFile file("${project.rootDir.absolutePath}/debug.keystore")
            keyAlias "androiddebugkey"
            keyPassword "android"
            storePassword "android"
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.debug
            debuggable true
            minifyEnabled false
            multiDexEnabled true
            testCoverageEnabled false
        }
    }

Google Cloud Platform

  1. In android directory execute
    fastlane init
  2. Add firebase app distribution plugin
    fastlane add_plugin firebase_app_distribution
  3. Add to Gemfile fastlane version e.g.
    gem "fastlane", "=2.200.0"
  4. Add to android/fastlane/Pluginfile firebase app distribution version e.g.
    gem 'fastlane-plugin-firebase_app_distribution', "=0.3.2"
  5. Copy android/fastlane/Fastfile from Flutter CI Test to your app
  6. Run gem install bundler -v 2.3.0 next bundle install and add generated ios/Gemfile.lock to VCS
  7. Setup fastlane supply
  8. Provide information about app in Google Play

Enable Google Play Android Developer API in Google Cloud Platform.

App Store Connect

  1. Create App ids (must be the same as you created in Firebase App Distribution) here.
  2. Create app in App Store Connect.
  3. Create App Store Connect API Key and set App Store Connect API variables (GitHub secrets).

iOS fastlane configuration

  1. In ios directory execute
    fastlane init
  2. Add firebase app distribution plugin
    fastlane add_plugin firebase_app_distribution
  3. Add to Gemfile fastlane version e.g.
    gem "fastlane", "=2.200.0"
  4. Add to ios/fastlane/Pluginfile firebase app distribution version e.g.
    gem 'fastlane-plugin-firebase_app_distribution', "=0.3.2"
  5. Copy ios/fastlane/Fastfile from Flutter CI Test to your app
  6. Set team ID in ios/fastlane/Appfile Team ID can be found here
  7. Run gem install bundler -v 2.3.0 next bundle install and add generated ios/Gemfile.lock to VCS
  8. Setup fastlane match

More information about fastlane configuration can be found here

Set required environment variables (GitHub secrets)

  • Services accounts Firebase App Distribution Service Account json key currently the same for all flavors
    • CI_TEST_FIREBASE_SERVICE_ACCOUNT_PRODUCTION
    • CI_TEST_FIREBASE_SERVICE_ACCOUNT_STAGING
    • CI_TEST_FIREBASE_SERVICE_ACCOUNT_DEVELOPMENT
  • Firebase application ID (available in Firebase Project settings)
    • CI_TEST_ANDROID_FIREBASE_APP_ID_PRODUCTION
    • CI_TEST_ANDROID_FIREBASE_APP_ID_STAGING
    • CI_TEST_ANDROID_FIREBASE_APP_ID_DEVELOPMENT
    • CI_TEST_IOS_FIREBASE_APP_ID_PRODUCTION
    • CI_TEST_IOS_FIREBASE_APP_ID_STAGING
    • CI_TEST_IOS_FIREBASE_APP_ID_DEVELOPMENT
  • Upload Key (keystore)
    • KEYSTORE_KEY_ALIAS – set when generating upload key
    • KEYSTORE_KEY_PASSWORD – set when generating upload key
    • KEYSTORE_STORE_PASSWORD – set when generating upload key
    • UPLOAD_KEYSTORE_FILE – android upload key encoded in base64
  • Play Store publisher account json key (service account json key generated in setup fastlane supply step)
    • CI_TEST_GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE
  • App store (variables for App Store Connect Api, should be set during creating App Store Connect API Key)
    • APP_STORE_CONNECT_API_KEY_ISSUER_ID
    • APP_STORE_CONNECT_API_KEY_KEY
    • APP_STORE_CONNECT_API_KEY_KEY_ID
    • MATCH_PASSWORD – password to decrypt profiles, created during setup fastlane match
    • FASTLANE_MATCH_GIT_DEPLOY_KEY – Certificates repository deploy key (read-only), created during setup fastlane match
  • API URLs
    • CI_TEST_API_URL_PRODUCTION
    • CI_TEST_API_URL_STAGING
    • CI_TEST_API_URL_DEVELOPMENT

GitHub Actions

GitHub Actions workflows are located in .github/workflows directory.

There are 8 workflows:

Future improvements

Currently GitHub Actions doesn’t support environment variables (non-secret) that can be shared between workflows, so environment variables must be set for each workflow e.g.

env:
  FLUTTER_CHANNEL: 'stable'
  FLUTTER_VERSION: '2.8.1'
  JAVA_VERSION: '17.0.1+12'
  RUBY_VERSION: '3.0.3'
  BUNDLER_VERSION: '2.3.0'


There you go. You should be able to create an app template using GitHub Actions yourself now. You’re welcome to comment this post. I’ll do my best to answer promptly.

Bartosz Gasztych Mobile Developer

Popular posts

From Hype to Hard Hats: Practical Use Cases for AI chatbots in Construction and Proptech.

From Hype to Hard Hats: Practical Use Cases for AI chatbots in Construction and Proptech.

Remember the multimedia craze in the early 2000s? It was everywhere, but did it truly revolutionize our lives? Probably not. Today, it feels like every piece of software is labeled "AI-powered." It's easy to dismiss AI chatbots in construction as just another tech fad.

Read more
Fears surrounding external support. How to address concerns about outsourcing software development?

Fears surrounding external support. How to address concerns about outsourcing software development?

Whether you’ve had bad experiences in the past or no experience at all, there will always be fears underlying your decision to outsource software development.

Read more
What do you actually seek from external support? Identify what’s preventing you from completing a project on time and within budget

What do you actually seek from external support? Identify what’s preventing you from completing a project on time and within budget

Let’s make it clear: if the capabilities are there, a project is best delivered internally. Sometimes, however, we are missing certain capabilities that are required to deliver said project in a realistic timeline. These may be related to skills (e.g. technical expertise, domain experience), budget (hiring locally is too expensive) or just capacity (not enough manpower). What are good reasons for outsourcing software development?

Read more
Mobile Apps

Get your mobile app in 3 easy steps!

1

Spec out

with the help of our
business analyst

2

Develop

design, implement
and test, repeat!

3

Publish

get your app out
to the stores


back to top