Firebase — Fastlane Integration for Automatic deployment

vijay sn
5 min readMay 26, 2021

As a mobile developer (iOS and Android), you need to deploy apps consistently for Testing and release it to the stores. It would be almost the same set of things that we will be doing while releasing the app.

A lot of time and Manual work is involved in the deployment of testing applications to internal stakeholders which is a part of the routine tasks. It is also repetitive.

Pain points:

  • Manual Effort
  • Time Consumption
  • Repetitive work

Fastlane — the savior:

We can minimize the time and manual effort for deployment by integrating Fastlane with Firebase App distribution.

Fastlane provides automatic deployment solutions with various distribution methods like Firebase, Testflight, etc. By making use of Fastlane, we can deploy applications easily from multiple targets with a single-line command. It streamlines the deployment process Notifies various communication platforms like Slack, Teams, Skype about the build deployment to keep the stakeholders notified about the deployment.

For delivering the application to QA for testing, We can make use of Firebase with Fastlane setup to easily distribute the application with different variants to the given set of users. We can deploy applications using a single line command and we can have different lanes to build different targets based on the business case.

Firebase App Distribution

When your project runs on agile scrum and if you need to release applications to internal stakeholders more than once for a week, then Firebase App distribution is the best option. Firebase not only provides app distribution for iOS and Android, it includes an integrated system in which you can do much more than just distributing your application.

The release process is very simple in Firebase, you will

  • Upload your IPA or APK file
  • Update release notes
  • Add tester's email to invite them for testing your application.

This is indeed a manual process and requires some time (15 minutes) of manual effort for every build release and if you work in a project that requires two build releases per day, then your valuable 30 minutes will be spent on this recurring task per day. That’s our primary goal for this blog, we are going to replace it with one second of effort and we are going to do much more than just a build release.

What is Fastlane?

Fastlane is an open-source platform aimed at simplifying Android and iOS deployment. It lets you automate every aspect of your development and release workflow.

Fastlane groups actions into different lanes and here we are going to maintain different lanes for different targets. By calling the lane, you will get a specific target to generate a build and you can group multiple lanes and include it as a single lane.

Fastlane Setup:

Fastlane can be installed in multiple ways. The preferred method is with Bundler. Fastlane can also be installed directly through with Homebrew (if on macOS).

If you have Homebrew installed in your macOS, then all it takes is a single command

brew install fastlane

Navigate your terminal to your project’s directory and run

fastlane init

Fastlane — Firebase Integration:

For integrating Firebase App distribution with Fastlane, We need to install the firebase plugin like below:

fastlane add_plugin firebase_app_distribution

In Fastlane — Fastfile, We can do specific operations by using the lane, A basic Lane exactly looks like this:

lane appStage do |values|

build_app(scheme: ‘MyApp-Staging’, export_method: ‘development’)

emails = values[:test_email] ? values[:test_email] : nil

groups = values[:test_group] ? values[:test_group] : nil

firebase_app_distribution(

app: “your-unique-firebase-app-id”,

testers: “test1@mail.com”,

groups: “group-1,group-2”,

release_notes: “Feature 1 — Release”,

firebase_cli_path: “/usr/local/bin/firebase”

)

end

Each Firebase App has a unique application id, which will be used along with the target that we are aiming to build and release. We can include individual testers, groups of testers, and also release notes in the distribution lane to avoid manual efforts in the Firebase console.

Once the Set up is done, we can execute a specific lane to distribute the app in Firebase using this command.

bundle exec fastlane betaStage

The build will get generated in the Fastlane folder, and also it will be distributed to firebase directly with a list of defined parameters mentioned in the lane.

Fastlane — Slack Integration:

Now we have completed sending the build to Firebase for everyone to test the app.

But Don’t we need to get notified of that? We may not monitor the console or check emails all the time.

For this purpose, we can use webhooks from Slack to get the notification for every successful build release through the execution of the lane. The following code should be included inside the lane section for slack integration.

slack(

slack_url: “ webhook -url,

channel: “#channelname”,

success: true,

message: “Release Notes”,

payload: {

“🗓 Build Date” => Time.new.to_s,

“🌎 Environment” => “App- Staging”

},

default_payloads: [:git_branch, :test_result, :last_git_commit_hash],

)

We can get the webhook-url for the channel, we want to notify for build release and we can even get the branch and also last commit id in which the build gets generated. This will give us more clarity about the app distributed.

What’s Next?:

Fastlane helps automate things like Crashlytics Symbolication, Test Flight App deployment, Third-party messaging tool notification, Screenshots for the App store, etc.

We can understand other integrations and automation by going through their website: http://fastlane.tools/. We can make use of Fastlane integration to reduce manual efforts and to save a lot of time.

--

--