Files

165 lines
4.2 KiB
Ruby

opt_out_usage
default_platform(:ios)
APP_IDENTIFIER = "ch.protonmail.protonmail"
NOTIFICATION_EXTENSION_IDENTIFIER = "ch.protonmail.protonmail.notifications"
SHARE_EXTENSION_IDENTIFIER = "ch.protonmail.protonmail.Share"
DEVELOPER_KEYCHAIN_NAME = "PROTONMAIL_IOS_CERTIFICATE_KEYCHAIN"
CERTIFICATE_PATH = "fastlane/Certificates.p12"
XCODEPROJ = "ProtonMail.xcodeproj"
APP_TARGET = "ProtonMail"
UNIT_TESTS_SCHEME = "AllUnitAndSnapshotTests"
UI_TESTS_SCHEME = "ProtonMailUITest"
XCODEGEN_CONFIGURATION_FILE_PATH = "../project.yml"
PERFORMANCE_PLAN_NAME="PerformanceTests"
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
platform :ios do
def select_xcode
xcodes(version: '26.2', select_for_current_build_only: true)
end
def set_up_keychain
create_keychain(
name: DEVELOPER_KEYCHAIN_NAME,
password: ENV["DEVELOPER_KEYCHAIN_PASSWORD"],
default_keychain: false,
add_to_search_list: true,
unlock: true,
timeout: 3600
)
import_certificate(
keychain_name: DEVELOPER_KEYCHAIN_NAME,
keychain_password: ENV["DEVELOPER_KEYCHAIN_PASSWORD"],
certificate_path: CERTIFICATE_PATH,
certificate_password: ENV["DISTRIBUTION_CERTIFICATE_PASSWORD"]
)
end
def tear_down_keychain
delete_keychain(
name: DEVELOPER_KEYCHAIN_NAME
)
end
def get_xcode_profile
ids = [
APP_IDENTIFIER,
NOTIFICATION_EXTENSION_IDENTIFIER,
SHARE_EXTENSION_IDENTIFIER
]
ids.each do |id|
get_provisioning_profile(
app_identifier: id,
readonly: true,
)
end
end
def get_latest_build_number
latest_testflight_build_number(
version: get_version_number(xcodeproj: XCODEPROJ, target: APP_TARGET),
initial_build_number: 0
)
end
def current_marketing_version
sh("sed -n 's/.*MARKETING_VERSION: \\(.*\\)/\\1/p' #{XCODEGEN_CONFIGURATION_FILE_PATH}").strip
end
def add_tag_and_push(build_number)
project_version = current_marketing_version
branch_name = ENV['CI_COMMIT_REF_NAME']
sh("git fetch origin #{branch_name}:#{branch_name}")
sh("git checkout #{branch_name}")
add_git_tag(tag: "v#{project_version}_#{build_number}")
push_to_git_remote
end
lane :decode_distribution_certificate do
sh "base64 -D -o Certificates.p12 <<< $DISTRIBUTION_CERTIFICATE"
end
desc "Run unit tests"
lane :tests do
select_xcode
run_tests(
scheme: UNIT_TESTS_SCHEME,
clean: true,
reinstall_app: true,
result_bundle: true,
xcargs: "-skipPackagePluginValidation"
)
end
desc "Run UI Performance Tests"
lane :uitests_performance do
# more info: https://keith.github.io/xcode-man-pages/xcodebuild.1.html#TEST_RUNNER__VAR_
['ET_USER', 'ET_USER_PWD', 'LOKI_ENDPOINT', 'CERTIFICATE_IOS_SDK_PASSPHRASE'].each { |env_var_key|
ENV["TEST_RUNNER_#{env_var_key}"] = ENV[env_var_key]
}
run_tests(
scheme: UI_TESTS_SCHEME,
max_concurrent_simulators: 1,
concurrent_workers: 1,
include_simulator_logs: true,
prelaunch_simulator: true,
reset_simulator: true,
result_bundle: true,
testplan: PERFORMANCE_PLAN_NAME,
xcargs: "-skipPackagePluginValidation"
)
end
desc "Deploy to Test Flight"
lane :deploy do |options|
begin
select_xcode
decode_distribution_certificate
set_up_keychain
# parameters are passed from Apple App Store Connect integration: https://gitlab.protontech.ch/apple/inbox/mail/-/settings/integrations
app_store_connect_api_key
get_xcode_profile
latest_build_number = get_latest_build_number
new_build_number = latest_build_number + 1
increment_build_number(build_number: new_build_number)
build_app(
scheme: options[:scheme],
clean: true,
output_directory: "outputs/",
export_method: "app-store",
xcargs: "-skipPackagePluginValidation"
)
sentry_debug_files_upload
upload_to_testflight(
team_name: "Proton Technologies AG",
skip_waiting_for_build_processing: true
)
add_tag_and_push(new_build_number)
ensure
tear_down_keychain
end
end
lane :whats_new do
app_store_connect_api_key
set_changelog
end
end