Creating & storing your Google Play service account key
Storing your Android signing key
Set up your GitLab workflow .yml file
1. Copy Fastline files
Fastlane is a Ruby library created to automate common mobile development tasks. Using Fastlane, you can configure custom “lanes” which bundle a series of “actions” that perform tasks that you’d normally perform using Android studio. You can do a lot with Fastlane, but for the purposes of this tutorial, we’ll be using only a handful of core actions.
Create a Fastlane folder at the root of your project and copy the following files:
Fastlane
Storing Your Secrets in GitLab CI/CD Variables
GitLab provides a way to store encrypted CI/CD variables, similar to GitHub’s repository secrets. To store your sensitive information securely.
Go to your GitLab project’s Settings.
Navigate to CI/CD > Variables
Add the following variables:
ANDROID_KEYSTORE_FILE: the base64-encoded .jks or .keystore file used to sign your Android builds. This will either be the keystore file associated with your upload key (if using Play App Signing), or your app signing key.
KEYSTORE_KEY_PASSWORD: the password associated with the keystore file
KEYSTORE_KEY_ALIAS: the key store alias
KEYSTORE_STORE_PASSWORD: the private key password
DEVELOPER_PACKAGE_NAME: your android app ID like com.example.app
PLAY_CONFIG_JSON: The base64-encoded service account key JSON.
Set Up Your GitLab CI/CD Pipeline
Create a .gitlab-ci.yml file at the root of your project to define your CI/CD pipeline. Below is an example of how you can structure your pipeline:
Trigger the Pipeline
Whenever you push a new tag to your GitLab repository, GitLab CI/CD will automatically trigger the defined pipeline, which will build and deploy your Android app using Fastlane.
Make sure to adjust the paths and dependencies according to your project’s structure and requirements. This setup will help you automate the deployment of your Android app on GitLab CI/CD.
Conclusion
By configuring GitLab CI/CD with the mingc/android-build-box Docker image, you can automate the Android app build process, making your development workflow more efficient and reliable. This automation frees up your time to focus on the core aspects of app development, ultimately helping you deliver high-quality Android apps more efficiently.