read

There are a number of ways to bump a build number.

One of the most suitable way for CI is by using the number of git commits. However, there is a big tradeoff when you do that. In your git checkout, the whole repo has to be fetched! This will be unnecessary slow.

Moreover, the git way can have collision when the CI runs on different branches.

The Best Source of Truth

Turns out, we can, and very well should, rely on where we distribute our releases. This is usually either:

  1. Apple Testflight
  2. Firebase Distribution

There are fastlane actions to grab the latest releases easily.

Firebase has a plugin to provide firebase_app_distribution_get_latest_release while fastlane’s testflight action has a latest_testflight_build_number.

This is the code if you’re using both of them.

lane :update_build_number do
  firebase_build = firebase_app_distribution_get_latest_release(
    app: ENV['FIREBASE_APP_ID'],
    firebase_cli_token: ENV['FIREBASE_TOKEN'],
  )
  
  next_build = [firebase_build[:buildVersion].to_i, latest_testflight_build_number].max + 1

  increment_build_number(build_number: next_build)
end

Image

@samwize

¯\_(ツ)_/¯

Back to Home