Android CI/CD Automation: GitHub Actions & Fastlane

In professional engineering teams, developers never manually build APKs on their local laptops and email them to stakeholders. Continuous Integration and Continuous Deployment (CI/CD) automates the entire software release pipeline: executing unit tests on every pull request, enforcing code style rules, compiling signed Android App Bundles, and publishing them directly to the Google Play Store.

Complete GitHub Actions Android CI Workflow (.github/workflows/android.yml)

name: Android CI / CD Pipeline

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    name: Build & Run Tests
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up Java Development Kit (JDK 17)
        uses: actions/setup-java@v4
        with:
          distribution: 'zulu'
          java-version: '17'
          cache: 'gradle'

      - name: Grant Execute Permission for Gradle Wrapper
        run: chmod +x gradlew

      - name: Run Android Lint Check
        run: ./gradlew lintDebug

      - name: Run Local Unit Tests
        run: ./gradlew testDebugUnitTest

      - name: Build Release Android App Bundle (AAB)
        run: ./gradlew bundleRelease
        env:
          SIGNING_KEY_STORE: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
          KEY_STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
          KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
          KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}

      - name: Upload Build Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: app-release-bundle
          path: app/build/outputs/bundle/release/app-release.aab

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. Why should keystore credentials never be committed to Git?

If your upload keystore file or passwords leak to GitHub, anyone can sign malicious updates under your package name. Always store credentials as Base64-encoded strings inside encrypted **GitHub Actions Secrets**.

Q2. What is Fastlane in mobile CI/CD?

Fastlane is an open-source tool that automates tedious mobile development tasks like taking localized app screenshots for store listings, managing beta testing groups in Firebase App Distribution, and deploying AABs to Google Play tracks.

Q3. How does Gradle caching speed up GitHub Actions builds?

By enabling `cache: 'gradle'`, GitHub Actions caches Gradle dependencies and build cache artifacts between runs, cutting build times from 15 minutes down to 2 minutes.

Explore Related Android Development Classes & Next Steps

Broaden your foundational and advanced Android application development skills across our curriculum:

Unit Testing & UI Testing

Execute automated unit tests and code coverage reports on pull requests.

Play Store Publishing Automation

Automate AAB generation and Play Console upload using Fastlane.

Gradle KTS Build Variants

Manage build variants (debug, staging, release) in CI workflows.

R8 Optimization in CI Pipelines

Generate release bundles with full optimization and sign with secrets.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!