Install Fastlane
brew install fastlane
cd MyApp
mkdir fastlane && cd fastlane
touch Fastfile
cd ..
Install Fastlane dependencies
- Install plugins handling version, version code on android
$ fastlane add_plugin increment_version_name increment_version_code
Should fastlane modify the Gemfile at path 'Gemfile' for you? (y/n) y
- Install plugin reading Json file (package.json)
fastlane load_json
desc 'Android: Increment versionCode and set versionName to package.json version.'
package = load_json(json_path: "./package.json")
private_lane :inc_ver_and do
increment_version_code(
gradle_file_path: "./android/app/build.gradle",
)
increment_version_name(
gradle_file_path: "./android/app/build.gradle",
version_name: package['version']
)
end
desc 'iOS: Increment build number and set the version to package.json version.'
private_lane :inc_ver_ios do
package = load_json(json_path: "./package.json")
increment_build_number(
xcodeproj: './ios/' + package['name'] + '.xcodeproj'
)
increment_version_number(
xcodeproj: './ios/' + package['name'] + '.xcodeproj',
version_number: package['version']
)
end
desc 'Bump build numbers, and set the version to match the pacakage.json version.'
lane :bump do
inc_ver_ios
inc_ver_and
end
- Add script into package.json file
- “npm version patch –no-git-tag-version”: Upate JS package version without making a commit
- “bundle exec fastlane bump”: Bump the android and iOS build numbers and update the version to match the JS side
{
...
"scripts": {
...
"bump-patch": "npm version patch --no-git-tag-version && bundle exec fastlane bump",
"bump-minor": "npm version minor --no-git-tag-version && bundle exec fastlane bump",
"bump-major": "npm version major --no-git-tag-version && bundle exec fastlane bump",
...
},
- Change “version” value in package.json and run
yarn bump-patch
Leave a Reply