Android CICD Save

This repo demonstrates how to work on CI/CD for Mobile Apps :iphone: using Github Actions :pill: + Firebase Distribution :tada:

Project README

Android-CICD

This repo demonstrates how to work on CI/CD for Mobile Apps :iphone: using Github Actions :pill: + Firebase Distribution :tada:

Getting Started

We are here setup a continious integration pipelines using Github Actions and a continious delivery using Firebase Distribution ⚡ ⚡

If you want to know a brief definition for the two terms CI/CD 🙆‍♂️, Checkout out the quotes :

  • Continuous Integration

    Is the practice of merging all developers' working copies to a shared mainline several times a day.

  • Continuous Delivery

    Is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, without doing so manually.

CI/CD

Workflows

  • 🚀 pre_check.yaml : This workflow have to check for lint, testing and static code analyzer
  • 🚀 build.yaml : This workflow have to build and deploy to firebase distribution

Getting Started With CI ⚡

To get start with build CI pipelines, you should use Actions tab or create a new YAML file, then you could setup your workflow, please checkout Metadata syntax for GitHub Actions :monocle_face:

How to create your own workflow

  1. name

Name of your workflow

  1. on

Control when the workflow will be triggerd

  1. jobs

Deterimne one or more jobs / pipelines to run for the workflow, but you have to specifiy some parameters to run the job

  • job_name

Pick up your own job name

  • runs_on

Specify your runner type

  • steps

Represent a squence of tasks will be exceuted for each job / pipeline, each step have a some of parameters

  • uses

One of step parameters, you can use it when your are trying to install enviornment or repository from marketplace

  • run

One of step parameters, you can use it when your are trying to hit a command

CI Sample :partying_face:

This workflow run as a lint checker for each Pushing on master branch :rocket:

name: Build lint checker report

on:
  push:
    branches: [ master ]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps: 
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Java JDK
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Build Lint
        run: ./gradlew lintDebug
    
      - name: Upload Build Lint Report
        uses: actions/upload-artifact@v2
        with:
          name: report
          path: app/build/reports/lint-results-debug.html
  • Checkout : This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
  • Setup Java JDK
  • Build Lint : Run lint report
  • Upload Build Lint Report : This uploads artifacts from your workflow allowing you to share data between jobs and store data once a workflow is complete.

Getting Started With CD ⚡

To get start with build CD pipelines, you should integrate your app with Firebase Distribution, then you could setup your workflow, please checkout Firebase Distribution for more how to integrate your app with firebase :monocle_face:

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.

CD Sample :partying_face:

This workflow builds a debug APK, then upload the artifact APK to a workflow dashboard and send another one to testers group on firebase distributions dashboard after each Pull Request on master branch 🚀

name: Integrate Firebase Distributions + Github Actions

on:
  pull_request_target:
    branches: [ master ]

jobs:
  builds:
    runs-on: ubuntu-latest
    steps: 
      - name: Checkout
        uses: actions/checkout@v2
        
      - name: Setup Java JDK
        uses: actions/setup-java@v1
        with:
         java-version: 1.8
        
      - name: Build Gradle
        run: ./gradlew build
    
      - name: Upload a Build Artifact
        uses: actions/upload-artifact@v2
        with:
          name: app
          path: app/build/outputs/apk/debug/app-debug.apk
          
      - name: Upload Artifact To Firebase App Distribution
        uses: wzieba/[email protected]
        with:
          appId: ${{ secrets.FIREBASE_ID }}
          token: ${{ secrets.FIREBASE_TOKEN }}
          groups: Android-CICD-Testers
          releaseNotes: "Hey! This my first integrate Firebase distributions with Github Actions"
          file: app/build/outputs/apk/debug/app-debug.apk   
  • Build Gradle : Build your APK.
  • Upload Artifact To Firebase App Distribution : This action uploads artifacts (.apk,.aab) to Firebase App Distribution.
  • appId : Get it from your project settings on firebase console.
  • token : Run this command firebase login:ci, for more informations about how to get your firbase token, check out Firebase CLI

Secrets : This path to encrypt your sensitive information, you can access it from Settings/Secrets Tab, for more info checkout out Encrypted Secrets

Screenshot from firebase distribution dashboard after sending the debug_app using Actions workflow

Release

How to integrate your project wih sonarcloud code analysis

Contributing

Don't hesitate to contribute with any updates or improves, just fork this repository, make the change you'd like and then submit a pull request.

Issues

Notice any issues with a repository? Please file a Github Issue in this repository.

License

The MIT License (MIT)

Copyright (c) 2021 MohamedGElsharkawy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Open Source Agenda is not affiliated with "Android CICD" Project. README Source: MGamalE/Android-CICD

Open Source Agenda Badge

Open Source Agenda Rating