Skip to content

Instantly share code, notes, and snippets.

@moatazeldebsy
Created June 6, 2021 15:21
Show Gist options
  • Save moatazeldebsy/b55a99574dad1ecb0b740d3b37178c28 to your computer and use it in GitHub Desktop.
Save moatazeldebsy/b55a99574dad1ecb0b740d3b37178c28 to your computer and use it in GitHub Desktop.
#### Setup ####
desc "Fetches development certificates and provisioning profiles"
lane :fetch_dev_certificates do
match(type: 'development', readonly: true, team_id: Bitrise::TeamId, app_identifier: Bitrise::AppIdentifier::Production)
match(type: 'development', readonly: true, team_id: Bitrise::TeamId, app_identifier: Bitrise::TopShelfAppIdentifier::Production)
end
desc "Fetches distribution certificates and provisioning profiles"
lane :fetch_distribution_certificates do
match(type: 'appstore', readonly: true, team_id: Bitrise::TeamId, app_identifier: Bitrise::AppIdentifier::Preview)
match(type: 'appstore', readonly: true, team_id: Bitrise::TeamId, app_identifier: Bitrise::AppIdentifier::AppleStore)
match(type: 'appstore', readonly: true, team_id: Bitrise::TeamId, app_identifier: Bitrise::AppIdentifier::Production)
end
#### Unit and UI Tests ####
desc "Run Unit tests"
lane :unit_tests do
run_tests(message: "Unit", scheme: "BitriseTests")
end
desc "Run UI Tests"
lane :ui_tests do
run_tests(message: "UI", scheme: "BitriseUITests")
end
#### Check Style ####
desc "Check style and conventions"
lane :lint do
swiftlint(
mode: :lint,
output_file: 'reports/swiftlint.txt',
config_file: 'fastlane/.swiftlint.yml'
)
end
#### Releases ####
desc "Release build to TestFlight"
lane :release do
ensure_git_status_clean
increment_build(app_identifier: Bitrise::AppIdentifier::Production)
gym
pilot(app_platform: 'ios')
post_to_slack(message: "New *Bitrise* available in TestFlight", success: true)
end
desc "Release a new version for the Apple Store"
lane :release_applestore do
ensure_git_status_clean
setup_applestore
increment_build(app_identifier: Bitrise::AppIdentifier::AppleStore)
setup_applestore_provisioning_profiles
gym
pilot(app_platform: 'ios')
post_to_slack(message: "New *Bitrise AppleStore* available in TestFlight", success: true)
end
desc "Generate screenshots"
lane :screenshots do
snapshot
end
#### Private Lanes####
private_lane :run_tests do |opts|
scan(scheme: opts[:scheme])
post_to_slack(message: "*#{opts[:message]} Tests*: All tests successfully passed", success: true)
end
private_lane :post_to_slack do |options|
if ENV["SLACK_URL"]
message = options[:message]
success = options[:success]
slack(message: "iOS" + message + (success ? " :beers:" : " :bomb:"), success: success)
end
end
#### Configuration for BitrisePreview ####
private_lane :setup_preview do
setup_preview_display_name
setup_preview_app_identifier
end
private_lane :setup_preview_app_identifier do
update_app_identifier(plist_path: "Bitrise/Resources/Info.plist", app_identifier: Bitrise::AppIdentifier::Preview)
update_app_identifier(plist_path: "TopShelfExtension/Resources/Info.plist", app_identifier: Bitrise::TopShelfAppIdentifier::Preview)
end
private_lane :setup_preview_display_name do
update_info_plist(plist_path: "Bitrise/Resources/Info.plist", display_name: Bitrise::DisplayName::Preview)
end
private_lane :setup_preview_provisioning_profiles do
update_provisioning_profile_specifier(profile_specifier: Bitrise::ProvisioningProfiles::Preview)
update_provisioning_profile_specifier(profile_specifier: Bitrise::TopShelfProvisioningProfiles::Preview, target_name: 'TopShelfExtension')
end
#### Configuration for AppleStore ####
private_lane :setup_applestore do
setup_applestore_display_name
setup_applestore_app_identifier
end
private_lane :setup_applestore_app_identifier do
update_app_identifier(plist_path: "Bitrise/Resources/Info.plist", app_identifier: Bitrise::AppIdentifier::AppleStore)
end
private_lane :setup_applestore_display_name do
update_info_plist(plist_path: "Bitrise/Resources/Info.plist", display_name: Bitrise::DisplayName::AppleStore)
end
private_lane :setup_applestore_provisioning_profiles do
update_provisioning_profile_specifier(profile_specifier: Bitrise::ProvisioningProfiles::AppleStore)
end
#### Common ####
private_lane :increment_build do |options|
increment_build_number({
build_number: latest_testflight_build_number(app_identifier: options[:app_identifier], platform: 'appletvos') + 1
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment