Photo by Nattipat Vesvarute

Manage your mobile application version automatically with GitHub Actions

Automate the versioning of your application

Posted by Damien Aicheh on 07/15/2021 · 7 mins

When developing an application you always need to manage versions for your application. To deliver a new version of your application, one way to do it will be:

  • Upgrade the version of your application in code
  • Commit your code
  • Add a new version tag to your Git repository
  • Start your workflow to generate your new application package

This kind of process is too long and error prone, while the only thing you want is to have the same version between your Git tag and your application package delivered. So why not just read the Git tag?

Introducing new GitHub Actions

To solve this problem I developed a new set of free GitHub Actions to use in your workflow. These actions provide a way to extract the version from a Git repository tag and apply it to your project as you want.

Here there are:


To use one of these actions it’s easy, follow one of the links above and then click on Use latest version button. This will prompt a dialog with the yaml code to use it.

Use action

Extract the version from the tag

The first action is the most important one: extract-version-from-tag-action. To use it in your workflow you first need to set the actions/checkout@v2 with the fetch-depth property to 0. This will ensure that all the tags informations will be available.

- name: Checkout
  uses: actions/checkout@v2
    fetch-depth: 0 # Mandatory to use the extract version from tag action

- name: Extract version from tag
  uses: damienaicheh/extract-version-from-tag-action@v1.0.0

This will extract the version of the latest tag pushed to your Git repository, from the branch you selected to build your workflow. Then the action will assign each part of your tag to a global variable.

For example if you have a tag with a value of v1.2.3 or 1.2.3 this will automatically assign the global variables $MAJOR to 1, $MINOR to 2 and $PATCH to 3. In addition this action will compute the number of commits from the first commit on your branch to this tag and assign this value to $NUMBER_OF_COMMITS and if you want only the number of commits since your tag you can use $NUMBER_OF_COMMITS_SINCE_TAG. These 4 variables will then be usable in your workflow.yml.

Also the action supports pre-release tags so if you have an alpha version like this: v1.2.3-alpha6 the alpha6 will be assign to the variable $PRE_RELEASE and you can use it like the previous ones.

By convention the Git tags are defined like this: v(Major).(Minor).(Patch). But the extract-version-from-tag-action action also manages the tags defined without the v prefix.

This action can be used whatever the technology you use for your GitHub Actions.

Update your mobile application version

It’s now time to use the three others GitHub Actions to update your iOS and Android applications versions whatever the mobile technology you used.

  • update-ios-version-info-plist-action for the Info.plist
  • update-android-version-manifest-action for the AndroidManifest.xml
  • update-android-version-gradle-action for the build.gradle inside the app folder

These actions can be used with or without using the extract-version-from-tag-action action before.

Let’s assume you use the extract-version-from-tag-action action before, you will be able to use the variables inside the 3 actions like this:

For iOS to update the Info.plist:

- name: Update Info.plist
  uses: damienaicheh/update-ios-version-info-plist-action@v1.0.0
    info-plist-path: './path_to_your/Info.plist'
    bundle-short-version-string: '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}'
    bundle-version: ${{ env.NUMBER_OF_COMMITS }}
    print-file: true

For Android:

If you need to update the AndroidManifest.xml:

- name: Update AndroidManifest.xml
  uses: damienaicheh/update-android-version-manifest-action@v1.0.0
    android-manifest-path: './path_to_your/AndroidManifest.xml'
    version-code: ${{ env.NUMBER_OF_COMMITS }}
    version-name: '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}'
    print-file: true

If you need to update the build.gradle inside the app folder:

- name: Update gradle version for Android
  uses: damienaicheh/update-android-version-gradle-action@v1.0.0
    build-gradle-path: './path_to_your/build.gradle'
    version-code: ${{ env.NUMBER_OF_COMMITS }}
    version-name: '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}'
    print-file: true

The detail of each input parameters of these actions are also available directly on their repository or the GitHub Marketplace.

Customize the version

Notice that for these 3 actions you can set the value of the properties in different ways for example:

version-name: '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}'

you can concatenate them with whatever variable you previously define:

version-name: '${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}-${{ env.PRE_RELEASE }}-(${{ env.NUMBER_OF_COMMITS }})'

or simply use it like this:

version-name: '1.2.3'

Final touch

These actions are a first starting point to help developers managing their applications versions with GitHub Actions. Feel free to contribute to this project if you want.

Happy coding!

Do not hesitate to follow me on to not miss my next tutorial!