How to build and publish your React Native Android applications using GitLab CI
I'm currently setting up CI for my company and think it'd be a good idea to share (the results of) the hoops I went through :)
The tutorial would allow a person with a React Native project to:
- add CI (builds, tests) + CD (publishing to Play Store) with a simple
.gitlab-ci.yml(making use of existing container in Container Registry) or
- fork container-building repos to have a customised setup (again, with CR)
What is your audience?
- React Native developers with no specific requirements to experience: those who'd like to easily set up a CI/CD pipeline to automate and foolproof their deployment process
- Developers or devops who want to have a customized build / test / rollout process for their RN apps, with no lock-in and option to self-host
What are the requirements?
No specific hardware or software requirements beyond those necessary to use GitLab.
- React Native
- [wip] Publishing to Play Store
- Builds Docker image
In comparison to https://github.com/jangrewe/gitlab-ci-android:
- Makes use of Container Registry
As stated earlier, I'm already working on implementation of this, and here's what currently works:
- Android CI: Basically does what blog-posts#28 (closed), but with a Docker image and overall cleaner in my opinion.
- Android RN CI: Adds node and yarn on top of Android image.
- An actual project with CI enabled
- Multiple keys / multiple build jobs (various flavors)
- Verify GPG signature before executing anything on runner
Continuous Integration – a practice of automatically building and testing software on every push or merge (and before every merge) – allows you to quickly catch bugs or breakages; Continuous Delivery goes further with the concept by automatically deploying “good” builds to staging (or, in our case, to Google Play alpha track).
This post will guide you on setting up an effective CI/CD system for React Native Android apps on Gitlab CI with the power of Docker. You’ll be able to make the most of it if you’re already familiar with creating RN apps and git.
1. Build debug flavour from clean repo 2. Build release 2.1 Build locally 2.1.1 Set up release keys 2.2 Build on CI 2.2.1 Set up deploy keys 2.2.2 CI env vars 2.2.3 Set up SSH, download keystore 3. Version with git
4. Create initial entry for app on Play 5. Set up Play keys 6. Auto publish 6.1 Locally 6.2 From CI 7. Automate filling Play metadata 8. Publish to different tracks depending on branch / tag
"You now know how to CI RN"
https://gitlab.com/wldhx/reactNativeGitlabCIAndroidCDTest. A secrets repository was also created but is not public for obvious reasons.