Flutter beta deploy TeamCity config on Firebase App Distribution

Deploy your flutter apps to Firebase App Distribution

Mon, 19 Jun 2023

Heads up, this guide will walk you through a deployment pipeline to deploy your apps on Firebase App Distrubition. This guide already assumes that you set up your app on Apple and Android and already hit Get Started on the Firebase App distrubution section of your project

  1. Go to root project
  2. scroll down and click create template under “Build Configuration Templates”
  3. Under Version Control Settings I like to only do deployments for my main branch and pull requests. If you want to do the same set the Branch Filter to
+:<default>
+:refs/tags/*
  1. I use fastlane for all of my build steps. This is what my lane looks like for ios. You can alter this script however you want, in particular the release description section. I pull the latest release draft from github to add to the changes section. I generate this list using the Github Release Drafter action. These steps are not needed along with the crashlytics step. The crashlytics step just adds the .dSYM files to crashlytics to give us more detail on whats going on when we do receive a crash on ios
  desc "Push a new beta build to Firebase"
  lane :beta do |options|
	# Getting release description from github
	release = get_github_release(url: options[:github_url], version: options[:build_version], api_token: options[:github_token])

	# Getting flutter dependencies
	sh("flutter", "pub", "get")

	# Uploading debugging symbols to crashlytics.  We need the crashlytics pod to get the upload script so we must
	# install the pod first
	cocoapods(deployment: true)
	upload_symbols_to_crashlytics(dsym_path: options[:dsym_path], app_id: options[:app_id], binary_path:"./Pods/FirebaseCrashlytics/upload-symbols")

    firebase_app_distribution(
        app: options[:app_id],
        release_notes: release["body"],
        groups: "main", # Enter your group name
        ipa_path: options[:artifact_path]
    )
  end

Android lane

  desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do |options|
	# Getting release description from github
	release = get_github_release(url: options[:github_url], version: options[:build_version], api_token: options[:github_token])

  firebase_app_distribution(
      app: options[:app_id],
      release_notes: release["body"],
      groups: "main",
      android_artifact_type: "AAB",
      android_artifact_path: options[:artifact_path]
  )
end
  1. Next up is the build steps. Under Deploy Steps add 2. The first is Deploy iOS. Because this is a template I want this step to be optional. Under Add Condition add a new condition. The condition will be deploy_ios and set this to equals true. Set the Working Directory to ios and the custom script

    fastlane beta artifact_path:%system.teamcity.build.tempDir%/Runner.ipa github_url:%github_url% build_version:%version_name% github_token:%env.GITHUB_TOKEN% dsym_path:%system.teamcity.build.tempDir%/Runner.app.dSYM.zip app_id:%ios_app_id%
  2. The second step is Deploy Android. You want to do the same thing except make the conditional parameter deploy_android and set the working directory to android. For the script section put this in there. This will build your android app and override the build version and number

fastlane beta artifact_path:%system.teamcity.build.tempDir%/app-release.aab github_url:%github_url% build_version:%version_name% github_token:%env.GITHUB_TOKEN% app_id:%android_app_id%
  1. In the VCS trigger just set it to the branch you want to deploy. Currently I have my default branch always deploy to firebase
  2. Click create, the template should be finished now. Create a new build configuration off this template. The only thing you need to change is the Dependency section. Click on Add new Artifact Dependencies. In the depends on section select the build that is making the artifacts. Under Get artifacts from select Build from the same chain and for artifact rules put in
app-release.aab => %system.teamcity.build.tempDir%
Runner.ipa => %system.teamcity.build.tempDir%
Runner.app.dSYM.zip => %system.teamcity.build.tempDir%
  1. Click add new snapshot dependency and supply the same build that you did in the previous step. For options check off the following, Enforce revisions synchronization, Do not run new build if there is a suitable one, Only use successful builds from suitable ones
  2. Go to parameters and start to fill in the parameters. The version_name should be %dep.(your config where the artifacts are built name).version_name%, this will basically pull the semver version from the build. If you are using the github release for the changelog, specify your github repo. It should be in the format org/repo so if my org was Acme and my repo was MyAwesomeFlutterApp then the github_repo field should be Acme/MyAwesomeFlutterApp. Finally specify the android and ios app ids that are displayed in the settings section of your firebase project

Now you should be able to build and deploy to firebase!

Buy Me A CoffeeDigitalOcean Referral Badge
Loading...
Edward Beazer

Edward Beazer - I just like to build shit. Sometimes I get stuck for hours, even days while trying to figure out how to solve an issue or implement a new feature. Hope my tips and tutorials can save you some time.

DigitalOcean Referral Badge