virtually Android CI/CD pipeline with Github Actions: Demystifying Github Actions | by Ankur Anurag will cowl the newest and most present info as regards the world. get into slowly so that you perceive capably and appropriately. will enlargement your data easily and reliably

Producing and deploying Android builds has at all times been a ache level for Android builders. Tons of of improvement hours are wasted as we stare on the laptop display screen, ready for our construct to finish. That is the place CI/CD involves our rescue. There are numerous instruments for constructing CI/CD pipelines like Jenkins, CircleCI, Bitrise, TravisCI, and so forth. Github Actions is a brand new addition to this listing. It makes the entire technique of constructing a pipeline very straightforward and is totally free for public repositories. Yow will discover the costs right here.

On this article, I’d reveal use Github Actions to automate your Android construct and deployment course of.

One can create the workflow file by going to Actions tab > Configure Workflow your self.

It will take you to the YAML editor, the place we’ll outline our workflow in accordance with our want. A primary workflow construction appears to be like like this:

# Identify of your workflow
identify: Android Construct and Deployment Pipeline
# Outline on which Github occasion, workflow will set off
branches: [ master ]
branches: [ main ]
identify: Job 1
runs-on: ubuntu-latest
- identify: 'Verify Inputs'
run: echo 'Job 1'

Word that the YAML file is delicate to indentation

  1. Add a set off for Github occasions
branches: [ master ]
branches: [ main ]

You too can add triggers for merges, pull requests, and so forth.

2. Add help for handbook activation (if wanted)

description: 'The appliance Id/bundle identify'
required: true
description: 'The department from which you need the construct'
required: true
default: 'grasp'

3. Cost code

Default department:

- identify: Checkout the code to particular department
makes use of: actions/[email protected]

Particular department (department identify from Step 2 entries, can be arduous coded)

- identify: Checkout the code to particular department
makes use of: actions/[email protected]
ref: $ github.occasion.inputs.department

4. Configure JDK

We now have one predefined motion on the Github Actions Market. It handles the duty of downloading the JDK, unzipping it, configuring the JAVA_HOME approach and so forth

- identify: Arrange JDK
makes use of: actions/[email protected]
distribution: 'zulu'
java-version: '11'

5. Configure the Android SDK

We now have one motion for this step as properly. Obtain SDK, unzip, env variables, settle for licenses, it is all dealt with.

- identify: Setup Android SDK
makes use of: android-actions/[email protected]

6. Gradle caching (non-compulsory)

For this we’ll use this motion .

- makes use of: actions/[email protected]
path: |
key: $ runner.os -gradle-$ hashFiles('**/*.gradle*', '**/')
restore-keys: |
$ runner.os -gradle-

7. Make Gradle executable

We are going to use the bash command for this.

- identify: Make gradlew executable
run: chmod +x ./gradlew

8. Generate the artifact

For bundle:

- identify: Generate app bundle.
run: ./gradlew app:bundleRelease --stacktrace

For APKs:

- identify: Generate app APK.
run: ./gradlew assembleRelease --stacktrace

9. Signal the artifact

You probably have outlined the signing configuration within the gradle file, then this step shouldn’t be mandatory.

To signal the APK/Bundle, you’ll need KeyStore Password, Alias, Key Password. You’ll be able to outline them as world variables in Github on the group or repository degree. These secrets and techniques are encrypted and protected to make use of on Github Actions. To create secrets and techniques you may go to this hyperlink

- identify: Signal app bundle
run: |
jarsigner -keystore app/*.jks
-storepass $ secrets and techniques.KEY_STORE_PASSWORD -keypass $ secrets and techniques.KEY_PASSWORD
app/construct/outputs/bundle/launch/app-release.aab $ secrets and techniques.ALIAS

There is a motion for a similar. We are able to additionally use it.

- identify: Signal app bundle
makes use of: r0adkll/[email protected]
id: sign_app
releaseDirectory: app/construct/outputs/bundle/launch
signingKeyBase64: $ secrets and techniques.SIGNING_KEY
alias: $ secrets and techniques.ALIAS
keyStorePassword: $ secrets and techniques.KEY_STORE_PASSWORD
keyPassword: $ secrets and techniques.KEY_PASSWORD
# override default build-tools model (29.0.3) -- non-compulsory

10. Add the artifact to Github (non-compulsory)

In case you wish to entry the bundle/APK generated within the above steps, you may add it to Github. Will probably be obtainable for obtain inside the workflow.

- identify: Add Bundle
makes use of: actions/[email protected]
identify: signed_app_bundle
path: app/construct/outputs/bundle/launch/app-release.aab

11. Create Launch to Playstore

We are going to use a default motion for this objective.

To launch to the PlayStore, we want a service account json file, which is created from the PlayStore console. The steps concerned are past the scope of this text. You’ll be able to observe this hyperlink to create service account json file.

- identify: Create service_account.json
run: echo '$ secrets and techniques.SERVICE_ACCOUNT_JSON ' > service_account.json
- identify: Deploy to Play Retailer
makes use of: r0adkll/[email protected]
serviceAccountJson: service_account.json
packageName: $ github.occasion.inputs.app_id
releaseFiles: app/construct/outputs/bundle/launch/*.aab
observe: inside
whatsNewDirectory: whatsnew/
mappingFile: app/construct/outputs/mapping/launch/mapping.txt
inAppUpdatePriority: 5

I hope the article about Android CI/CD pipeline with Github Actions: Demystifying Github Actions | by Ankur Anurag provides perception to you and is helpful for including to your data

Android CI/CD pipeline with Github Actions: Demystifying Github Actions | by Ankur Anurag

By admin