Fastlane: increment build number without changing project file?

I am setting up fastlane to run the builds of our iOS app. Is there a way to increment the build number based on the latest TestFlight build and upload a build, but without changing the project file? I'd rather not pollute the Git history with build number changes. Currently the app is being built with Xcode Cloud and somehow it's managing to keep CURRENT_PROJECT_VERSION = 1 in the project file.

Unless I'm missing something I would basically have to do:

    current_version = get_version_number()
    previous_build_number = latest_testflight_build_number(
      api_key: api_key,
      app_identifier: app_identifier,
      version: current_version
    )
    
    current_build_number = previous_build_number + 1
    
    increment_build_number(
      build_number: current_build_number
    )
    
    build_ios_app(...)
    
    increment_build_number(
      build_number: 1
    )

Replies

This worked for me:

current_build_number = app_store_build_number(live: false, username: 'myusername@example.com', app_identifier: 'mybundle.identifier')
increment_build_number(xcodeproj: 'MyProject.xcodeproj', build_number: current_build_number + 1)