Setup Android Gradle based Firebase App Distribution with GitHub Actions CI

Search for a command to run...

No comments yet. Be the first to comment.
šš½ Hello there, I recently moved my primary blog at hossain.dev GitHub's Spark is a fantastic starting point for building modern React applications that uses spark-template as starting point. Once
šš½ Hello there, I recently moved my primary blog at hossain.dev TL;DR: I let AI write a JSON5 parser for me using just test cases and vibes. No deep knowledge, just TDD and Agentic AIs. Shockingly

šš½ Hello there, I recently moved my primary blog at hossain.dev Building is more fun with AIĀ š¤ Iāve had my GitHub Copilot subscription for over a year now, but I havenāt leveraged the service unti

šš½ Hello there, I recently moved my primary blog at https://hossain.dev/ Have you ever needed to save your Android Logcat logs for later analysis? I recently built a service-based Android app, and

šš½ Hello there, I recently moved my primary blog at https://hossain.dev/ ā¹ļø This is part of the self-learning log as I explore Docker and Portainer. Recently, I have been playing with Portainer āāa

This is a quick guide on how you can easily set up Github Actions CI workflow to automatically post APK to Firebase App Distribution on merge to release or master (or soon to be known as main) branch.
Firebase already has an excellent guide š on how to set up the Gradle task on your Android project to post APK to App Distribution. However, I will quickly touch those areas using the easiest path āļø.
PREREQUISITE: You already have Firebase project setup for the app with
google-services.jsonfile in your Android app project.
On your root build.gradle file add the Gradle plugin
dependencies {
// .. more existing dependencies here
classpath 'com.google.firebase:firebase-appdistribution-gradle:2.0.0' // see official guide for latest versions
}
Next, apply the plugin in your Android appās build.gradle and distribution properties. See the official guide for the full list of supported parameters.
apply plugin: 'com.google.firebase.appdistribution'
android {
buildTypes {
release { // NOTE: `debug` can have different cofigs
firebaseAppDistribution {
releaseNotes="Release notes at bit.ly/notes"
groups="qa" // see docs for more options
}
}
}
}
Firebase has 3 different documented ways you can authenticate to be able to upload the APK. Generating the token is one of the easiest that I will focus on with snapshot images so that you can easily relate to it.

From the root of your android app project, run following Gradle command which will give you a URL to authenticate for the Firebase project that app uses.
./gradlew appDistributionLogin
Copy the URL https://accounts.google.com/o/..../auth/cloud-platform and paste it in browser and login with the Google account which has write access to the Firebase project.
Once authorized, you should get `FIREBASE_TOKEN` in the console. Save it for later use.
Go to your GitHub project and the FIREBASE_TOKEN as secret property.

Based on git-flow, we want to setup the CI job such that whenever we merge commit to master branch it triggers the release build. You can obviously customize the behavior based on your need.
name: Firebase App Distribution
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Firebase App Distribute
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: ./gradlew assembleRelease appDistributionUploadRelease
Thatās it, you should have a working GitHub workflow that automatically sends APK to Firebase App Distribution as soon as there is a commit on master branch.
See pull-request I made to add support for this in one of my side projects.
If you find any issues please let me know I will try to help. Good luck š
Firebase App Distributionāāāhttps://firebase.google.com/docs/app-distribution
GitHub Actionsāāāhttps://help.github.com/en/actions
Pull Request to support Firebase App Distributionāāāhttps://github.com/amardeshbd/android-police-brutality-incidents/pull/117/files