Building React Native Projects with Native Code: Part 6
Exploring the master branch workflow.

This article is part of a series starting with Building React Native Projects with Native Code: Part 1.
Master Branch (Release) Workflow
Once we are confident with the release branch, we will merge all the code and generate the final application (in this case an Android APK) to be manually uploaded to a store.

The steps are:
- Update the version of the application (more on this below)
- Merge release into master (and pushing to GitHub)
- Push GIT tags to GitHub (more on this below)
- Merge release into develop-native (and pushing to GitHub)
- Cherry-pick JavaScript-only commits into develop
- Manually update version in package.json and app.json in develop (more on this later); commit and pushing to GitHub.
Master Branch (Hot-Fix) Workflow
While not shown in the above diagram, we anticipate that we will need to apply hot-fixes to the master branch through the normal feature / pull-request process (including building review applications). The release process for a hot-fix is the same as a regular release (the outline steps) except the merge to master happens with a pull request.

Updating the Version of the Application
The application’s version is duplicated across three files that we need to keep synchronized:
- package.json (the source of truth)
- app.json (used by Expo)
- android/app/build.gradle (used by Android)
Additionally, we want to use this version to tag (GIT) the commit containing the final release (this is why we need to also push GIT tags).
To ensure we keep everything synchronized, we will build off the Node.js (npm) feature that updates versions that synchronizes package.json and a GIT tag.
As before, we keep the build scripts synchronized across all the branches by creating them in develop and merging them into develop-native and then in-turn merging develop-native into master.
We first add a package that helps read / write JSON files:
yarn add json --dev
We then update:
package.json
Observations:
- The version script in package.json is special as it is called as part of the Node.js (npm) command to update versions
- This depends on two scripts: version-expo.sh and version-android.sh; wrote them as shell scripts (it has been awhile since I wrote this many shell scripts)
version-expo.sh
version-android.sh
Observation:
- Since these scripts are run on your workstation we will have to account for the differences in sed on macOS. Requires you to add the flags -i “.bak” -E to the two sed commands. You also have to remove the backup file at the end rm ${FILE_NAME}.bak
With all this in place, right before we merge release into master, we run the command npm version with one of patch, minor, or major (semantic versioning), e.g.,
npm version patch
By the way, the reason we have to manually update package.json and app.json in the develop branch is because it does not contain the a build.gradle file (so do not want to cherry-pick the final commit).
Wrap Up
While I was originally thinking about continuing this series incorporating an iOS build into the mix, I decided that this series was too long as it is.
For those who made (suffered) it to this point; hopefully you found it helpful.