How To Automate App Releases using Fastlane and SemVer for Hybrid Applications
Tags: fastlane, reactnative, automation, hybridapps
Published: 2021-08-10 13:22:23

![Placeholder image for article](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q875yqvd5hutjcw5ws6b.png)

> **NOTE**: This tool/implementation is useful for when you have both iOS and Android binary applications residing within the same repository (usually a **React Native application**) or hybrid app development tools which produce iOS and Android apps. However, it can be customisable to your needs with a little re-configuration.

# The Story

Imagine if we could automate the entire app versioning process for our mobile applications by just typing in whether you want to bump it by:

- **Major**
- **Minor**
- or **Patch**

Imagine if you don’t have to worry about the app versioning process of knowing what is already in production and what version we need to bump it to?

**Lo and behold, the App Release Management (ARM) tool.** 🎉

> **NOTE**: Semantic versioning MAJOR, MINOR, and PATCH is the de facto standard you use to version your applications. Please refer to this [link](https://semver.org/) to find out more about SemVer standards.

# Fancy word, but what does it actually do?

It pretty much does what is mentioned above. The process is as follows:

1. It will fetch the latest versions from TestFlight and Google Play Console respectively.
2. It will show you a summary of what the versions are.
3. If both Android and iOS match, the tool will select either one of them to use as the base of bumping the version.
4. The tool will prompt you whether you would like to bump it based on major, minor, or patch
5. Based on the input, the tool will run a SemVer operation in calculating the next iteration in the version and display the results for you.
6. If you’re happy with the result, you may press yes to proceed.
7. It will update the following files for you:
    1. `package.json`
    2. `android/app/build.gradle`
    3. `ios/ProjectName.xcodeproj/project.pbxproj`
8. Operation completed!

# It all looks fancy, but why this approach?

Well, imagine if you are a product owner or a new engineer who is new to the application code and is required to manage the App Releases. This tool will aid them in completing their task with ease, without worrying about configuring the wrong version code bump by accident.

# Ok cool, how do I set it up?

1. Please refer to the [documentation README](https://github.com/jeiman/devops-fun/tree/main/development/app-release-management-tool) file for detailed instructions on how to set up the tool.
2. Clone the [devops-fun](https://github.com/jeiman/devops-fun) repository.
3. Once completed, navigate to **development > app-release-management-tool** folder.
4. Ensure that the `.env` file is present before proceeding any further. Refer to the README file for more information.
5. Run `fastlane` command.
6. Choose Option 1.
7. The rest are pretty self-explanatory thereafter.

# What if I want to manually bump the version via a tool?

You may run the `bump-version.sh` and pass in a version code as an argument: `./development/app-release-management-tool/bump-version.sh 3.2.0`

# What does it look like?

![CLI tool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56d2r8lq56xqfaxan4gd.png)

Based on the image above, the following actions occur:

- It will do a check against your iOS TestFlight build number and Google App Version and identify if the versions match (*Please refer to the [README.md](https://github.com/jeiman/devops-fun/blob/main/development/app-release-management-tool/README.md) file on how to set up a service connection to the respective stores in order to retrieve the app details programmatically*).
- If they do, it will display your current version in the App stores and will ask you for input, whether you want to bump the **major**, **minor,** or **patch**.
- Based on your input, it will use the `semver.sh` script to perform the necessary version bump according to the Semantic Versioning standards.
- If they don't match up, you'll be defaulted to using the `bump-version.sh` which requires manual input of your SemVer for your application - ie `./bump-version.sh 2.2.0`

I hope this article has proven beneficial and useful to your release management process. If you have any inquiries, please reach out to me. Happy automating your release process! Do leave a comment or recommendations on improving the tool.

# Resources

- [https://github.com/jeiman/devops-fun](https://github.com/jeiman/devops-fun)
- [https://github.com/jeiman/devops-fun/tree/main/development](https://github.com/jeiman/devops-fun/tree/main/development)
- [https://semver.org/](https://semver.org/)

# References

- [https://jontejada.com/blog/assets/semver02.png](https://jontejada.com/blog/assets/semver02.png)
- [https://github.com/fsaintjacques/semver-tool](https://github.com/fsaintjacques/semver-tool)