Automating Android and iOS Distribution with the wzieba Firebase GitHub Action

The integration of continuous integration and continuous deployment (CI/CD) pipelines into mobile application development has become a critical component for maintaining rapid release cycles and ensuring quality assurance. The wzieba/Firebase-Distribution-Github-Action serves as a pivotal bridge between GitHub Actions and Firebase App Distribution, enabling developers to automate the upload of application artifacts, specifically .apk, .aab, and .ipa files, directly to the Firebase console. Written in Shell, this third-party action is not certified by GitHub but operates under its own terms of service, privacy policy, and support documentation. It addresses a specific need in the mobile development workflow: the seamless transition from a successful build to a distributed test version for internal testers and stakeholders.

Understanding the Action and Its Workflow

The primary function of the wzieba/Firebase-Distribution-Github-Action is to upload build artifacts to Firebase App Distribution. This automation eliminates the manual friction of downloading a build from a CI server and uploading it to the Firebase console. The action is designed to fit into a standard GitHub Actions workflow, typically triggering on a push event or a merge request. The process begins with the checkout of the source code, followed by the setup of the necessary Java Development Kit (JDK) environment, such as JDK 1.8, and the execution of the build command, commonly ./gradlew assembleRelease for Android projects.

Once the build is complete and the artifact is generated, the action takes over. It requires specific inputs to authenticate with Firebase and identify the target distribution groups. The action supports authentication via a service account credential file, which has become the standard method as token-based authentication is being deprecated by the Firebase tools team. The action parses the provided credentials, authenticates with the Firebase API, and uploads the specified file to the designated release track. Upon successful upload, the action can provide links to the release in the Firebase console, a shareable link for testers, and a direct download link for the binary, which expires after one hour.

Authentication and Security Configuration

Security and authentication are central to the configuration of this GitHub Action. The action supports two primary methods for authentication, though the recommended approach has shifted significantly in recent updates.

Service Account Credentials

The modern and supported method for authentication involves using a Service Account private key JSON file. This requires the generation of a service account key within the Firebase console. The content of this JSON file must be stored as a secret in the GitHub repository. In the GitHub Actions workflow, this secret is referenced using the serviceCredentialsFileContent input. The action decodes this content to create the necessary credential file for the Firebase CLI to use. This method is preferred because it aligns with current security standards and avoids the deprecation of legacy token-based methods.

Legacy Token Authentication

Earlier versions of the action and older workflows utilized an upload token generated via the firebase login:ci command. This token was stored as a secret, typically named ANDROID_FIREBASE_TOKEN. However, the Firebase tools team has issued warnings that token authentication will soon be deprecated. Developers using this method are strongly advised to migrate to the Service Account method to ensure future compatibility and security compliance. The action's version history highlights this transition, with updates specifically addressing the shift away from token-based authentication.

Input Parameters and Configuration Details

The wzieba/Firebase-Distribution-Github-Action accepts a variety of input parameters that allow for fine-grained control over the distribution process. These parameters are defined in the with section of the GitHub Actions workflow file.

  • appId: The unique App ID associated with the Firebase project. This identifier is found on the General Settings page of the Firebase console and is required to direct the upload to the correct application.
  • serviceCredentialsFileContent: The content of the Service Credentials private key JSON file. This is the primary authentication method in current versions.
  • file: The path to the artifact that needs to be uploaded. This can be an .apk, .aab, or .ipa file. The path must correspond to the output location of the build step, such as app/build/outputs/apk/release/app-release-unsigned.apk.
  • groups: A comma-separated list of distribution groups to which the release should be shared. These groups are defined within the Firebase App Distribution interface.
  • testers: A comma-separated list of email addresses of testers who should receive invitations to test the new build.
  • releaseNotes: Optional notes describing the release. If not specified, the action will automatically generate release notes using the last commit's hash, author, and message. Alternatively, a path to a plain text file can be provided to use custom release notes.
  • debugFlag: A boolean flag that, when set to true, prints verbose log output to assist in troubleshooting and debugging the upload process.

Performance Optimizations in Recent Versions

The evolution of the wzieba/Firebase-Distribution-Github-Action has been marked by significant performance improvements. In version 1.6.0, the action underwent a major optimization that reduced the execution time from approximately three minutes and thirty-five seconds to just twenty-five seconds. This improvement was achieved by transitioning from a dynamically built Docker image to a pre-built Docker image stored in the GitHub container registry. The use of a pre-built image eliminates the overhead of building the environment from scratch for each workflow run, drastically speeding up the process.

Subsequent versions, such as 1.7.0 and 1.7.1, have focused on compatibility and internal improvements. Version 1.7.1 updated the base image to node:20-alpine to ensure compatibility with the latest versions of Firebase tools. These updates demonstrate the maintainer's commitment to keeping the action efficient and up-to-date with the changing landscape of node.js and Firebase SDKs.

Integration with Android Signing and Google Play

While the wzieba/Firebase-Distribution-Github-Action focuses on Firebase distribution, it is often part of a broader CI/CD strategy that includes signing the app and uploading to Google Play. This integration requires careful management of secrets and configuration files.

Android App Signing

For Android applications, the build process often requires a keystore for signing the release APK or AAB. The keystore can be generated using the keytool command:

bash keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

The keystore must be encoded in base64 and stored as a GitHub secret, typically named ANDROID_SIGNING_KEY. The action r0adkll/sign-android-release or similar tools can decode this secret to create the keystore file required for signing. Additional secrets are needed for the alias, keystore password, and key password:

  • ANDROID_ALIAS: The alias of the signing key.
  • ANDROID_KEY_STORE_PASSWORD: The password for the keystore.
  • ANDROID_KEY_PASSWORD: The private key password.

Uploading to Google Play

In addition to Firebase distribution, developers may choose to upload the signed Android App Bundle (.aab) to Google Play's internal track for testing. This can be achieved using the r0adkll/upload-google-play action. This action requires a service account JSON file with the necessary permissions to upload to Google Play. The configuration includes:

  • serviceAccountJsonPlainText: The content of the service account JSON file.
  • packageName: The package name of the Android application.
  • releaseFiles: The path to the AAB file.
  • track: The release track, such as internal.
  • inAppUpdatePriority: The priority for in-app updates.

It is crucial to ensure that the Android developer account and the internal track are configured to accept new builds before attempting this upload.

Practical Implementation Example

A typical GitHub Actions workflow that builds an Android app and uploads it to Firebase App Distribution might look like the following. This example incorporates the use of JDK 1.8, the Gradle build command, and the wzieba/Firebase-Distribution-Github-Action with service account authentication.

```yaml
name: Build & upload to Firebase App Distribution

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

  - name: set up JDK 1.8
    uses: actions/setup-java@v1
    with:
      java-version: 1.8

  - name: build release
    run: ./gradlew assembleRelease

  - name: upload artifact to Firebase App Distribution
    uses: wzieba/Firebase-Distribution-Github-Action@v1
    with:
      appId: ${{ secrets.FIREBASE_APP_ID }}
      serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
      groups: testers
      file: app/build/outputs/apk/release/app-release-unsigned.apk

```

This workflow checks out the code, sets up the Java environment, builds the release APK, and then uploads it to Firebase. The appId and serviceCredentialsFileContent are pulled from GitHub secrets, ensuring that sensitive credentials are not exposed in the workflow file. The groups parameter specifies the tester group, and the file parameter points to the generated APK.

Conclusion

The wzieba/Firebase-Distribution-Github-Action provides a robust and efficient solution for automating the distribution of mobile applications to testers via Firebase App Distribution. Its evolution from a token-based system to a service account-based architecture reflects the broader industry shift towards more secure and sustainable authentication methods. The significant performance improvements in recent versions, particularly the reduction in execution time through the use of pre-built Docker images, make it a highly efficient choice for CI/CD pipelines. By integrating this action with Android signing processes and Google Play uploads, developers can create a comprehensive automated workflow that streamlines the release process, reduces manual errors, and accelerates feedback loops from testers. As mobile development continues to demand faster iteration cycles, tools like this play a crucial role in maintaining agility and quality in the development process.

Sources

  1. OBytes Handbook
  2. SRCLOG Firebase Distribution GitHub Action
  3. FXIS AI Firebase App Distribution GitHub Action
  4. GitHub Releases for wzieba/Firebase-Distribution-Github-Action
  5. GitHub Marketplace Firebase App Distribution

Related Posts