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

roughly Android CI/CD pipeline with Github Actions: Demystifying Github Actions | by Ankur Anurag will lid the newest and most present advice roughly the world. edit slowly consequently you comprehend competently and appropriately. will accumulation your data properly and reliably

Producing and deploying Android builds has at all times been a ache level for Android builders. A whole lot of growth hours are wasted as we stare on the pc display, 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 many others. Github Actions is a brand new addition to this listing. It makes the entire technique of constructing a pipeline very simple and is totally free for public repositories. You’ll find the costs right here.

On this article, I’d show learn how to 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.

This may take you to the YAML editor, the place we’ll outline our workflow in line with our want. A primary workflow construction seems to be 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: 'Test Inputs'
run: echo 'Job 1'

Be aware that the YAML file is delicate to indentation

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

You may also add triggers for merges, pull requests, and many others.

2. Add assist for guide activation (if wanted)

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

3. Fee code

Default department:

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

Particular department (department identify from Step 2 entries, may also be laborious coded)

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

4. Configure JDK

Now we have one predefined motion on the Github Actions Market. It handles the duty of downloading the JDK, unzipping it, configuring the JAVA_HOME method and many others

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

5. Configure the Android SDK

Now we 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 (elective)

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’ll use the bash command for this.

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

8. Generate the artifact

For package deal:

- 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 will not be essential.

To signal the APK/Bundle, you’ll need KeyStore Password, Alias, Key Password. You may outline them as international variables in Github on the group or repository stage. These secrets and techniques are encrypted and protected to make use of on Github Actions. To create secrets and techniques you possibly can 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) -- elective

10. Add the artifact to Github (elective)

In case you wish to entry the package deal/APK generated within the above steps, you possibly can add it to Github. It will likely 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’ll use a default motion for this goal.

To launch to the PlayStore, we’d like a service account json file, which is created from the PlayStore console. The steps concerned are past the scope of this text. You may comply with 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
monitor: inside
whatsNewDirectory: whatsnew/
mappingFile: app/construct/outputs/mapping/launch/mapping.txt
inAppUpdatePriority: 5

I hope the article nearly Android CI/CD pipeline with Github Actions: Demystifying Github Actions | by Ankur Anurag provides keenness to you and is beneficial for accumulation to your data

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