Skip to content

Instantly share code, notes, and snippets.

@DevGW
Created December 29, 2022 13:44
Show Gist options
  • Save DevGW/e08b66e6f7155dbdce5f0d9d38f0a811 to your computer and use it in GitHub Desktop.
Save DevGW/e08b66e6f7155dbdce5f0d9d38f0a811 to your computer and use it in GitHub Desktop.
React :: Fastlane (auto versioning for mobile)
command line (assuming gem fastlane is installed):
fastlane add_plugin increment_version_name increment_version_code load_json
in package.json scripts:
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"bump-patch": "npm version patch && bundle exec fastlane bump",
"bump-minor": "npm version minor && bundle exec fastlane bump",
"bump-major": "npm version major && bundle exec fastlane bump",
"version": "auto-changelog -p"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "auto-changelog.hbs",
"unreleased": true,
"commitLimit": false,
"sortCommits": "date-desc"
},
in /fastlane/Fastfile
/// begin
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
/// end
////////////// commands ///////////////
npm run bump-patch
npm run bump-minor
npm run bump-major
//// auto changelog
npm install -g auto-changelog
/// add to package.json scripts
"version": "auto-changelog -p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment