6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/nixenvironment/deployer.rb', line 6
def self.deploy(deploy_host, deploy_dir, deploy_user, deploy_password, deploy_itunesconnect_user, deploy_team_name, deliver_deploy, deployment_names, skip_working_copy_check)
build_env_vars = BuildEnvVarsLoader.load
raise 'Error! Working copy is not clean!' unless BuildEnvVarsLoader.working_copy_is_clean? unless skip_working_copy_check
ipa_product = build_env_vars[IPA_PRODUCT_KEY]
ipa_product_resigned_device = build_env_vars[IPA_PRODUCT_RESIGNED_DEVICE_KEY]
ipa_product_resigned_adhoc = build_env_vars[IPA_PRODUCT_RESIGNED_ADHOC_KEY]
ipa_product_resigned_appstore = build_env_vars[IPA_PRODUCT_RESIGNED_APPSTORE_KEY]
ipa_bundle_id = build_env_vars[IPA_BUNDLE_ID_KEY]
ipa_bundle_id_resigned_device = build_env_vars[IPA_BUNDLE_ID_RESIGNED_DEVICE_KEY]
ipa_bundle_id_resigned_adhoc = build_env_vars[IPA_BUNDLE_ID_RESIGNED_ADHOC_KEY]
ipa_bundle_id_resigned_appstore = build_env_vars[IPA_BUNDLE_ID_RESIGNED_APPSTORE_KEY]
current_app_version = build_env_vars[CURRENT_APP_VERSION_KEY]
current_build_version = build_env_vars[CURRENT_BUILD_VERSION_KEY]
name_for_deployment = build_env_vars[NAME_FOR_DEPLOYMENT_KEY]
name_for_deployment_resigned_device = build_env_vars[NAME_FOR_DEPLOYMENT_RESIGNED_DEVICE_KEY]
name_for_deployment_resigned_adhoc = build_env_vars[NAME_FOR_DEPLOYMENT_RESIGNED_ADHOC_KEY]
name_for_deployment_resigned_appstore = build_env_vars[NAME_FOR_DEPLOYMENT_RESIGNED_APPSTORE_KEY]
if deployment_names.present?
names = deployment_names.scan(/(?:\w|'[^']*')+/).map! {|name| name.tr("'", '')}
ipas_count = 0
ipas_count += 1 if name_for_deployment.present?
ipas_count += 1 if name_for_deployment_resigned_device.present?
ipas_count += 1 if name_for_deployment_resigned_adhoc.present?
ipas_count += 1 if name_for_deployment_resigned_appstore.present?
raise 'Deployment names count does not match ipa files count!' if ipas_count != names.count
ipa_index = 0
if name_for_deployment.present?
deployment_name = names[ipa_index]
name_for_deployment = deployment_name if deployment_name != '_'
ipa_index += 1
end
if name_for_deployment_resigned_device.present?
deployment_name = names[ipa_index]
name_for_deployment_resigned_device = deployment_name if deployment_name != '_'
ipa_index += 1
end
if name_for_deployment_resigned_adhoc.present?
deployment_name = names[ipa_index]
name_for_deployment_resigned_adhoc = deployment_name if deployment_name != '_'
ipa_index += 1
end
if name_for_deployment_resigned_appstore.present?
deployment_name = names[ipa_index]
name_for_deployment_resigned_appstore = deployment_name if deployment_name != '_'
end
end
executable_name = build_env_vars[EXECUTABLE_NAME_KEY]
app_dsym = build_env_vars[APP_DSYM_KEY]
sdk = build_env_vars[SDK_NAME_KEY]
ipa_count = 0
if ipa_product.present? && File.exist?(ipa_product)
ipa_count += 1
deploy_internal(deploy_host, deploy_dir, deploy_user, deploy_password, nil, nil, nil,
ipa_bundle_id, ipa_product, current_app_version, current_build_version, name_for_deployment, executable_name, app_dsym, sdk)
end
if ipa_product_resigned_device.present? && File.exist?(ipa_product_resigned_device)
ipa_count += 1
ipa_bundle_id_resigned_device = ipa_bundle_id if ipa_bundle_id_resigned_device.blank?
deploy_internal(deploy_host, deploy_dir, deploy_user, deploy_password, nil, nil, nil,
ipa_bundle_id_resigned_device, ipa_product_resigned_device, current_app_version, current_build_version, name_for_deployment_resigned_device,
executable_name, app_dsym, sdk)
end
if ipa_product_resigned_adhoc.present? && File.exist?(ipa_product_resigned_adhoc)
ipa_count += 1
ipa_bundle_id_resigned_adhoc = ipa_bundle_id if ipa_bundle_id_resigned_adhoc.blank?
deploy_internal(deploy_host, deploy_dir, deploy_user, deploy_password, nil, nil, nil,
ipa_bundle_id_resigned_adhoc, ipa_product_resigned_adhoc, current_app_version, current_build_version, name_for_deployment_resigned_adhoc,
executable_name, app_dsym, sdk)
end
if ipa_product_resigned_appstore.present? && File.exist?(ipa_product_resigned_appstore)
ipa_count += 1
ipa_bundle_id_resigned_appstore = ipa_bundle_id if ipa_bundle_id_resigned_appstore.blank?
deploy_internal(deploy_host, deploy_dir, deploy_user, deploy_password, deploy_itunesconnect_user, deploy_team_name, deliver_deploy,
ipa_bundle_id_resigned_appstore, ipa_product_resigned_appstore, current_app_version, current_build_version, name_for_deployment_resigned_appstore,
executable_name, app_dsym, sdk)
end
raise 'Nothing to upload!' if ipa_count == 0
end
|