Flutter beta deploy TeamCity config on Firebase App Distribution
Deploy your flutter apps to Firebase App Distribution
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
- Go to root project
- scroll down and click create template under “Build Configuration Templates”
- 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 theBranch Filter
to
+:<default>
+:refs/tags/*
- 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
-
Next up is the build steps. Under
Deploy Steps
add 2. The first isDeploy iOS
. Because this is a template I want this step to be optional. UnderAdd Condition
add a new condition. The condition will bedeploy_ios
and set this toequals true
. Set theWorking Directory
to ios and the custom scriptfastlane 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%
-
The second step is
Deploy Android
. You want to do the same thing except make the conditional parameterdeploy_android
and set the working directory toandroid
. 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%
- In the VCS trigger just set it to the branch you want to deploy. Currently I have my default branch always deploy to firebase
- 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 onAdd new Artifact Dependencies
. In the depends on section select the build that is making the artifacts. UnderGet artifacts from
selectBuild from the same chain
and forartifact rules
put in
app-release.aab => %system.teamcity.build.tempDir%
Runner.ipa => %system.teamcity.build.tempDir%
Runner.app.dSYM.zip => %system.teamcity.build.tempDir%
- 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
- 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!