Build app with github-action and upload to Firebase App Distribution
Often, having testers test apps can be a tedious task. But now, it’s much more convenient and even free. Below is how you can achieve this by using GitHub Actions and Firebase App Distribution.
Firebase App Distribution makes distributing your apps to trusted testers painless. By getting your apps onto testers’ devices quickly, you can get feedback early and often. And if you use Crashlytics in your apps, you’ll automatically get stability metrics for all your builds, so you know when you’re ready to ship.
GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.
Play with following:
Part 1: Prepare your github project
At Android studio, create a project with below folder name
Insert project base information, please written down “package name”, it will used for next step.
OK. your project was created like this
Part 2: Prepare your google cloud project at Google Cloud Console
After finish, You will see like this
Part 3: Prepare your firebase project
Go to your firebase console:
Part 4: Add Firebase to your Android App
Package name should be same with above step!
After create a firebase project, you will see this screen. And then click your Android project
You will see you App ID, like 1:xxxxxxxx…:android:xxxxxxx…. , please write it down for next step use.
Setup test user account at your firebase console
Part 5: Get firebase token
Login firebase CLI
- install https://firebase.google.com/docs/cli
- login with your account
firebase login:ci
After “Allow”
Part 6: Prepare the key(s), which is used for build the app and deploy to firebase distribution.
We are using https://github.com/wzieba/Firebase-Distribution-Github-Action to help to deploy our app to firebase distribution.
- appId: Got from part 2 already ✅
- serviceCredentialsFileContent: step from https://github.com/wzieba/Firebase-Distribution-Github-Action/wiki/FIREBASE_TOKEN-migration ❓
(Remark: there have some unknow result cannot use) - token: Got from part 54+ already ✅
Part 7: Step up github action file
Go back your github repository. Add two key:
- FIREBASE_APP_ID
- CREDENTIAL_FILE_CONTENT
- FIREBASE_TOKEN
Finally, you will see like this
Part 8: Create“android.yaml” to let github action know to build
Create android.yaml” into your android project, and stored at
Sample of android.yaml
name: Android CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: build release
run: ./gradlew assembleDebug
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1.5.1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
#token: ${{secrets.FIREBASE_TOKEN}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: app/build/outputs/apk/debug/app-debug.apk
Part 9: Finally step
- Commit and push your code to your repo.
- You can check the build result at your github
👏 Congratulation, you will got this email when built is successful 👏