How to Increment the Build Number in CI
Stores reject a build whose number is not higher than the last upload, so derive it from GITHUB_RUN_NUMBER or bump it with fastlane.
Tie the build number to github.run_number for a monotonic value, or use fastlane's increment_build_number. iOS uses CFBundleVersion; Android uses versionCode.
Steps
- Use
${{ github.run_number }}as a monotonic build number. - iOS: set
CFBundleVersionviaagvtoolorincrement_build_number. - Android: pass the value into
versionCodevia a Gradle property.
Fastfile
Fastfile
lane :bump do
increment_build_number(
build_number: ENV["GITHUB_RUN_NUMBER"],
xcodeproj: "MyApp.xcodeproj"
)
endGotchas
- The build number only needs to increase; the marketing version (
CFBundleShortVersionString) is separate. - For Android, read the value in Gradle:
versionCode System.getenv("GITHUB_RUN_NUMBER").toInteger().