Giter Club home page Giter Club logo

androidsampleci_cd's Introduction

AndroidSampleCI_CD

This sample Android project is used to practice Github Actions CI/CD

Setup fastlane

  • Create a Gemfile in the root directory of your Android project
  • Then just run the following command: sudo gem install fastlane -NV
  • Setup Fastlane using this command: fastlane init and follow the prompts to fill in the details about your app: package name, Path to the json secret file, Download existing metadata and setup metadata management (y) -> it will create Appfile and Fastfile in fastlane folder
  • Type fastlane test to check the setup -> it will print out fastlane.tools finished successfully if the setup successful done
  • Add the firebase plugin fastlane add_plugin firebase_app_distribution
  • Type command in root folder of project to see all actions of plugin firebase_app_distribution bundle exec fastlane action firebase_app_distribution
  • Getting the Firebase App ID: go to firebase console -> add project -> add app -> copy App ID in project settings
  • Go to Google cloud platform -> select project created from firebase -> create a new service account -> add role 'Firebase Admin' 'Firebase App Distribution Admin' 'Cloud Storage - Storage Object Creator' 'Cloud Storage for Firebase Admin' , then create key json file download and add into project name firebase_credentials.json or copy json into github secrets
  • To run fastlane local it need to run this export FIREBASE_APP_ID=YOUR_APP_ID
  • Configure Firebase App Distribution: Create a new directory FirebaseAppDistributionConfig under the root directory of your project. Create a new file groups.txt in the created directory. Create a new file release_notes.txt in the same directory.
  • create distribute lane (in Fastfile)
  • Run local by command fastlane distribute
  • Use firebase cli token instead of firebase_credentials.json
    • Install firebase tool npm install -g firebase-tools
    • Type command firebase login:ci it will print firebase cli token
    • Type this command to test firebase cli token firebase projects:list --token FIREBASE_CLI_TOKEN -> list all projects in firebase account
  • Add bundletool plugin fastlane add_plugin bundletool this tool will extract an universal apk from .aab file to distribute it to firebase, app center, store, ...

Setup github action:

  • convert firebase credentials file to base64 string use command base64 -i firebase_credentials.json > firebase_credentials.json.b64
  • add into github secrets: FIREBASE_CREDENTIALS, FIREBASE_APP_ID
  • create workflow distribute.yml
  • Push code to main branch to see how github actions distribute workflow run and distribute apk to firebase app distribution

Create keystore cmd

keytool -genkey -v -keystore YOUR_FILE_NAME.keystore -alias YOUR_ALIAS_NAME -storepass YOUR_ALIAS_PWD -keypass YOUR_ALIAS_PWD -keyalg RSA -validity 36500

Create base64

base64 -i firebase_credentials.json > firebase_credentials.json.b64

Get Firebase CLI Token

  • install firebase cli npm install -g firebase-tools firebase login:ci firebase logout -- token $token (call this to clear token)
  • check token firebase projects:list --token "$FIREBASE_TOKEN"

Encode your KeyStore file (.jks) to base64

  • $ openssl base64 -A -in demo_alpha.keystore -out demo_alpha.txt
  • copy text in demo_alpha.txt to github actions secrets

androidsampleci_cd's People

Contributors

phannguyensmg avatar itman85 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.