Set your build version on Bitrise automatically

You have already setup your app on Bitrise, and now you are ready to start to deploy the app to your users or QA. There might be several versions going out and it might cause you some headache if you cannot identify these versions easily.

You have already setup your app on Bitrise, and now you are ready to start to deploy the app to your users or QA. There might be several versions going out and it might cause you some headache if you cannot identify these versions easily. Why have conflicting merges and misunderstandings and long conversations on who did or didn't fix what or when... You can easily refer to the exact build on Bitrise if you get an error report from a tester. Differentiate the versions to know who uses which and to make sure everybody uses the up-to-date app! Use (semi)automated version control on Bitrise too! 🤓

In software versioning a typical version identifier consists of 3 numbers, divided by full stops, e.g.: 3.4.2 (major.minor.build) Numbers are generally assigned in increasing order and correspond to new developments in the software.

Versions should be tracked in git repository. You can set version numbers in Info.plist, and you can update them manually there too. It is advised to do set the major and minor numbers by hand to be able to manage versions as you can decide which is a bigger or a smaller update. As for the build numbers, in a CI/CD environment it is useful to update the build while the build is happening.

On Bitrise there are steps to do just that: Set Xcode Project Build Number for iOS and Set Android Manifest Version Code and Name for Android. These steps insert the build number into the info.plist. If you did track versions otherwise earlier, you can offset these numbers to your existing numbering, so you don't have to start it all over again.

Android 🤖

This is how it looks in reality for Android:


---
format_version: '4'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
app:
  envs:
  - opts:
      is_expand: false
    GRADLE_BUILD_FILE_PATH: build.gradle
  - opts:
      is_expand: false
    GRADLEW_PATH: "./gradlew"
workflows:
  deploy:
    steps:
    - [email protected]:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - [email protected]: {}
    - [email protected]: {}
    - [email protected]:
        title: Do anything with Script step
    - [email protected]: {}
    - [email protected]:
        inputs:
        - manifest_file: "$BITRISE_SOURCE_DIR/app/AndroidManifest.xml"
        - version_code_offset: '0'
        - version_name: 1.0.0
    - [email protected]:
        inputs:
        - gradle_file: "$GRADLE_BUILD_FILE_PATH"
        - gradle_task: assembleRelease
        - gradlew_path: "$GRADLEW_PATH"
    - [email protected]: {}
    - [email protected]: {}
Copy code

iOS 📱

... and for iOS:


---
format_version: '3'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  primary:
    steps:
    - [email protected]:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - [email protected]: {}
    - [email protected]: {}
    - [email protected]:
        inputs:
        - plist_path: "$BITRISE_SOURCE_DIR/greg/Info.plist"
        - build_version_offset: '0'
        - build_short_version_string: '1.0'
    - [email protected]:
        inputs:
        - export_method: development
        - configuration: Debug
    - [email protected]:
        inputs:
        - export_method: app-store
        - team_id: TeamID
app:
  envs:
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: greg.xcodeproj
  - opts:
      is_expand: false
    BITRISE_SCHEME: greg
Copy code

Happy version counting! 🔢

No items found.
The Mobile DevOps Newsletter

Explore more topics

App Development

Learn how to optimize your mobile app deployment processes for iOS, Android, Flutter, ReactNative, and more

Bitrise & Community

Check out the latest from Bitrise and the community. Learn about the upcoming mobile events, employee spotlights, women in tech, and more

Bitrise Insights

Cache | Caching

Mobile App Releases

Learn how to release faster, better apps on the App Store, Google Play Store, Huawei AppGallery, and other app stores

Mobile DevOps

Learn Mobile DevOps best practices such as DevOps for iOS, Android, and industry-specific DevOps tips for mobile engineers

Mobile Testing & Security

Learn how to optimize mobile testing and security — from automated security checks to robust mobile testing and more.

Product Updates

Check out the latest product updates from Bitrise — Build Insights updates, product news, and more.

The Mobile DevOps Newsletter

Join 1000s of your peers. Sign up to receive Mobile DevOps tips, news, and best practice guides once every two weeks.