Last active
August 9, 2019 12:58
-
-
Save dayitv89/b26f321b577060b284d5621bdfc26284 to your computer and use it in GitHub Desktop.
react native fastlane setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# react_native_proj/fastlane/Fastfile | |
# react_native_proj/fastlane/fastlanespec.json | |
fastlane_version '2.120.0' | |
# before_all do | |
# # ensure_git_branch | |
# # ensure_git_status_clean | |
# # git_pull | |
# end | |
desc 'Ensure code setup is ready' | |
def ensure_code_setup(platform) | |
if Dir.exist?('../node_modules') | |
puts 'node_modules already available' | |
else | |
sh('npm run project:setup') | |
return | |
end | |
if platform == 'ios' | |
if Dir.exist?('../ios/Pods') | |
puts 'ios/Pods already available' | |
else | |
sh('npm run project:setup:ios') | |
end | |
end | |
end | |
desc 'Read the specs from the file' | |
def read_spec(key) | |
# react_native_proj/fastlane/fastlanespec.json | |
file = File.read('fastlanespec.json') | |
specs = JSON.parse(file) | |
specs[key] | |
end | |
platform :ios do | |
desc 'Create React Native bundle for iOS' | |
lane :create_rn_ios_bundle do | |
sh('npm run build-ios') | |
end | |
desc 'Manage certificates and provisioning profiles' | |
lane :manage_sign do | |
match(git_url: read_spec('git_certandprov'), | |
type: read_spec('cert_type'), | |
app_identifier: read_spec('ios_bundle_id'), | |
username: read_spec('apple_id'), | |
team_name: read_spec('apple_team_name') | |
) | |
end | |
desc 'Increment the build number (not the version number)' | |
lane :update_build_number do | |
current_build_number = latest_testflight_build_number( | |
app_identifier: read_spec('ios_bundle_id'), | |
username: read_spec('apple_id'), | |
team_name: read_spec('apple_team_name') | |
) | |
increment_build_number(build_number: current_build_number + 1, xcodeproj: read_spec('xcodeproj')) | |
end | |
desc 'ios build creation and push to testflight with increment build number' | |
lane :release do | |
ensure_code_setup('ios') | |
create_rn_ios_bundle | |
manage_sign | |
update_build_number | |
build_app(workspace: read_spec('workspace'), scheme: read_spec('scheme')) | |
upload_to_testflight(skip_waiting_for_build_processing: true, username: read_spec('apple_id')) | |
# # Commit the version bump | |
# commit_version_bump(xcodeproj: read_spec('xcodeproj')) | |
# # Push the new commit and tag back to your git remote | |
# push_to_git_remote | |
# # Add a git tag for this build. This will automatically | |
# # use an appropriate git tag name | |
# add_git_tag | |
# slack(message: 'Successfully uploaded a new App Store build') | |
end | |
end | |
platform :android do | |
desc 'Create React Native bundle for iOS' | |
lane :create_rn_android_bundle do | |
sh('npm run build-android') | |
end | |
desc 'Increment the build number (not the version number)' | |
lane :update_build_number do | |
increment_build_number | |
end | |
lane :release do | |
ensure_code_setup('android') | |
create_rn_android_bundle | |
update_build_number | |
# gradle(task: 'clean', project_dir: 'android/') | |
# gradle(task: 'assemble', build_type: 'Release', project_dir: 'android/') | |
# # Uploads the APK built in the gradle step above and releases it to all production users | |
# upload_to_play_store(track: 'internal') | |
# # hockey | |
# # Commit the version bump | |
# git_commit(path: ['./android/gradle.properties'], message: 'Bump versionCode') | |
# # Push the new commit and tag back to your git remote | |
# push_to_git_remote | |
# # Add a git tag for this build. This will automatically | |
# # use an appropriate git tag name | |
# add_git_tag | |
# slack(message: 'Successfully uploaded a new App Store build') | |
end | |
end | |
# after_all do |lane| | |
# # This block is called, only if the executed lane was successful | |
# # Notify at slack | |
# end | |
error do |lane, exception| | |
# slack(message: exception.message, success: false) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"git_certandprov": "git@github.com:<user>/ios-fastlane-certs.git", | |
"ios_bundle_id": "<bundle_id>", | |
"xcodeproj": "./ios/<project_name>.xcodeproj", | |
"workspace": "./ios/<project_name>.xcworkspace", | |
"scheme": "<scheme_name>", | |
"cert_type": "appstore", | |
"apple_id": "<apple_user_email_id>", | |
"apple_team_name": "<apple_team_name>", | |
"android_bundle_id": "<bundle_id>" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FASTLANE_DONT_STORE_PASSWORD=1 FASTLANE_PASSWORD='<some_pwd>' MATCH_PASSWORD='<git_cert_pwd>' fastlane ios release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment