How to handle versioning with fastlane for iOS/android


digging into fastlane for the first time on a react native project, and in the process of getting a demo version up for internal testing on both the google play store, and testflight.

After following some tutorials for getting the android bundle up successfully, I ended up with some lanes that do increment both the versionCode and versionName, then bundle and push to the google play store via the supply command.

Now I’m moving onto some iOS lanes, and I’m wondering the best way to sync these up. Ideally, I’d like to use the package.json version as the one source of truth for this, but I’m lost a little on the best way to tie it all in, so I’m asking for some advice/workflows that others have found successful with fastlane and building/versioning their ios/android apps. Thanks!

Here are my current android lanes.

  desc "Build a version of the app, that allows params for task and type"
  lane :build do |options|
    build_task = options.fetch(:build_task, "bundle")
    build_type = options.fetch(:build_type, "Release")

    gradle(task: "clean")
    gradle_params = {
      task: build_task,
      build_type: build_type,


  ##### ---------------------------------------------
  desc "Build and push a new internal build to the Play Store"
  lane :internal do
    supply_params = {
      track: "internal",
      release_status: "draft",
  ##### ---------------------------------------------
  desc "Increment build number and push to repository"
  lane :inc_build_number do |options|
    params = {
        :app_project_dir => 'app'

    # Specify a custom build number to be passed in
    if options[:build_number]
        params[:version_code] = options[:build_number].to_i

    new_version_code = Actions.lane_context[Actions::SharedValues::ANDROID_VERSION_CODE]
    UI.important("Incremented android version code to #{new_version_code}")

  ##### ---------------------------------------------
  desc "Increment version number and push to repository"
  lane :inc_version_number do |options|
    should_commit = options.fetch(:should_commit, true)
    commit_message = options.fetch(:commit_message, "android: bump version code & number[skip ci]")
    should_push = options.fetch(:should_push, true)

    ensure_git_status_clean if should_commit

    # increment build number first

    increment_type = options.fetch(:increment_type, "patch")
    new_version_params = options[:version]

    params = {
        app_project_dir: 'app',
        increment_type: increment_type,

    unless new_version_params.nil?()
        params[:version_name] = new_version_params

    new_version_name = Actions.lane_context[Actions::SharedValues::ANDROID_VERSION_NAME]
    UI.important("Incremented android version name to #{new_version_name}")

    if should_commit
        path = "android/app/build.gradle"
        git_add(path: path)
        git_commit(path: path, message: commit_message)
        push_to_git_remote if should_push


Source link

Leave a Reply

Your email address will not be published.