Automating Flutter Publishing with GitHub Actions & Firebase App Distribution

Zvi Karp
Zvi Karp
Jun 4 · 5 min read
Image for post
Image for post

One of the most important parts of freelancing is engaging the client in your development process. This tutorial will show you how to automatically send new versions of your Flutter app to your client with Firebase App Distribution and GitHub Actions.

Before You Start

  • You’ll need a basic knowledge of Flutter, Git, and GitHub 💪.
  • To follow this tutorial you need to have a Flutter project using Firebase. To create one, take a look at the Flutter Documentation and Firebase Documentation.

Note: This tutorial is Windows and Android-based. It hasn't been tested on any Apple devices.

The tutorial is divided into three parts: first, use Firebase App Distribution, then set up GitHub Actions, and lastly, merge the two.

Part 1: Firebase App Distribution

Firebase App Distribution allows you to share your new app release with groups of testers as quickly as sending an email! No more waiting for days for it to be approved on the Google Play Store. The reasons we use Firebase App Distribution are because it’s free to use, easy to set up, a “set and forget” process, and, most importantly, easy for your client to use. As we know, clients often have very little or no technical background, and you don’t want to send them apk files manually.

Let’s use Firebase App Distribution in an existing project:

Now you have a way to send your apk to a group of testers, but it needs to be done manually, and we are programmers, so let’s automate it!

Part 2: GitHub Actions

GitHub Actions is a CI/CD automation tool built into your GitHub workflow. It allows you, for example, to send automated messages to new contributors in your repo, or test your application before releasing it to production. It’s free for public repositories and some free computing minutes per month are included for private repositories. See GitHub Pricing for more details.

In this part, we create an action that attempts to build your application on every commit or pull request. We create a new branch “dev”, and every time we push from “dev” to “master”, GitHub builds your app and notifies you if it fails. The catch here is that we have some secret files that we don’t want to upload to GitHub (e.g. the google-services.json file for Firebase). These files are listed in the .gitignore file. So first, we need to encrypt the secret files and only then upload them to GitHub and provide GitHub with the keys to decrypt them. This is how to do it:

Now what’s left is to push to GitHub and check if the action passes. It might take a while for the action to run. You can see the progress by going to the
GitHub “Actions” tab.

Part 3: Firebase App Distribution with GitHub Actions

By now we have all the components working and tested 😎, the last step is to combine them. We extend the current GitHub Action so that, on a pull request to the “master” branch, it uploads the new version of the app to Firebase App Distribution.

First, we need to give GitHub Actions authentication information and permissions to your Firebase account.

All that’s left is to update the GitHub Action. Add the following lines to the end of main.yml. You can do this in the “dev” branch and then push your changes to GitHub.

OK, we’re all set! Create a pull request from “dev” to “master” and you can see the state of the action in the pull request. After it finishes, you should get an email from Firebase with the new version of the app 🤯. Now that you know it works, add the client’s email to the testers group in Firebase App Distribution so they get an email the next time the action runs.

Flutter Community

Articles and Stories from the Flutter Community

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store