Testing is always required whenever we build an app to ensure it functions properly in production. It might be time-consuming and inconvenient to send the application to the testers every time new code is merged into the codebase. So to solve this problem, CD pipelines can be used to deliver the software to the testers. In this article, we’ll be learning to build a CD pipeline for Android and send the APK to the testers group in Firebase.
Pre-requisites: Git, Github, Basic understanding of building CI/CD pipelines and GitHub Actions, Setup of Firebase.
Now as we know how to set up Firebase and have generated the TokenID, keep it safe as we’ll need the same TokenID while we’ll code our CD pipeline. So first of all go to Firebase and create a new project. Write the name of the project as you wish. Now follow the guidelines of setting up firebase in your android project. After you have added Firebase to your Android project, go to the Firebase Console, select your project, and scroll to the bottom of the console. Now click on See all Extension features. In Release and Monitor section, click on App Distribution -> Testers & Groups -> Add group. Name the group as “project-testers” and add your email id to it.
After that go back to the settings of your project and copy the AppID. Keep it safe, we will be using that too in our code.
Now, we can create our CD pipeline using GitHub actions and upload our APK to the testers group that we created in Firebase. Create a .yml file named releases.yml in .github/workflows directory under the project’s root directory. Start writing the below code in that file.
name: Build and Release
name: Upload APK to App Tester
- uses: firstname.lastname@example.org
- name: Setup JDK
- name: build release
run: bash ./gradlew assembleDebug
- name: upload artifact to Firebase App Distribution
appId: 'Enter you AppID here'
token: 'Enteer your TokenID here'
Whenever there will be a push of code in the master branch, this workflow will be triggered. It will then set up JDK and build that APK for release. After this is done, it will upload the file app/build/outputs/apk/debug/app-debug.apk to the project-testers group that we created in Firebase. Now commit this code, and you will see the workflow running in the Actions tab of your project on GitHub.
After the workflow run is finished, go to the releases tab of your project in firebase and you’ll see a release published over there.
In this way, the testers can download the app from there and can test it. Each time new code is pushed into the master branch, this workflow will trigger, and upload the APK for testing.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!