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

Popular posts

Augmented Reality as a trend in Mobile Development

Augmented Reality as a trend in Mobile Development

3D maps, realistic games, virtual showrooms and fitting rooms, interactive participation in a conference or concert, visiting museums and exhibitions. These are just a few examples of where Augmented Reality can be used. Applications created with the help of AR effectively combine the real world with the virtual one. Can your business also benefit from […]

Read more
How to use Natural Language Processing in Mobile App?

How to use Natural Language Processing in Mobile App?

The ability to communicate and interact using language is a remarkable skill. It distinguishes humans from other species and machines. Even the most advanced systems and technologies need specific, defined commands to take action. But what would happen if an application could interpret our language and, importantly, recognize the context of our speech? This is […]

Read more
5 Technology Trends Moving into 2021

5 Technology Trends Moving into 2021

What will technology trends dominate in 2021? We prepared statement of 5 the most popular, latest trends in business e.g. Artificial Intelligence, Agile Methodology. Read our article and know more about it!

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