deploygate 0.6.7 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,22 +21,27 @@ module DeployGate
21
21
  distribution_key = options.distribution_key
22
22
  server = options.server
23
23
 
24
- bundle_id = bundle_id(work_dir, options.configuration)
24
+ root_path = DeployGate::Xcode::Ios.project_root_path(work_dir)
25
+ workspaces = DeployGate::Xcode::Ios.find_workspaces(root_path)
26
+ analyze = DeployGate::Xcode::Analyze.new(workspaces, options.configuration)
27
+ bundle_id = analyze.target_bundle_identifier
28
+ developer_team = analyze.developer_team
29
+ member_center = DeployGate::Xcode::MemberCenter.new(developer_team)
25
30
 
26
31
  if server
27
- run_server(session, owner, bundle_id, distribution_key, args, options)
32
+ run_server(session, owner, bundle_id, distribution_key, member_center, args, options)
28
33
  else
29
- device_register(session, owner, udid, device_name, bundle_id, args, options)
34
+ device_register(session, owner, udid, device_name, bundle_id, member_center, args, options)
30
35
  end
31
36
  end
32
37
 
33
- def run_server(session, owner, bundle_id, distribution_key, args, options)
34
- DeployGate::AddDevicesServer.new().start(session.token, owner, bundle_id, distribution_key, args, options)
38
+ def run_server(session, owner, bundle_id, distribution_key, member_center, args, options)
39
+ DeployGate::AddDevicesServer.new().start(session.token, owner, bundle_id, distribution_key, member_center, args, options)
35
40
  end
36
41
 
37
- def device_register(session, owner, udid, device_name, bundle_id, args, options)
42
+ def device_register(session, owner, udid, device_name, bundle_id, member_center, args, options)
38
43
  if udid.nil? && device_name.nil?
39
- devices = fetch_devices(session.token, owner, bundle_id)
44
+ devices = fetch_devices(session.token, owner, bundle_id, member_center)
40
45
  select_devices = select_devices(devices)
41
46
  not_device if select_devices.empty?
42
47
 
@@ -44,7 +49,7 @@ module DeployGate
44
49
  else
45
50
  register_udid = udid || HighLine.ask(I18n.t('commands.add_devices.input_udid'))
46
51
  register_device_name = device_name || HighLine.ask(I18n.t('commands.add_devices.input_device_name'))
47
- device = DeployGate::Xcode::MemberCenters::Device.new(register_udid, '', register_device_name)
52
+ device = DeployGate::Xcode::MemberCenters::Device.new(register_udid, '', register_device_name, member_center)
48
53
 
49
54
  puts device.to_s
50
55
  if HighLine.agree(I18n.t('commands.add_devices.device_register_confirm')) {|q| q.default = "y"}
@@ -54,7 +59,7 @@ module DeployGate
54
59
  end
55
60
  end
56
61
 
57
- build!(bundle_id, args, options)
62
+ build!(bundle_id, member_center, args, options)
58
63
  end
59
64
 
60
65
  def register!(devices)
@@ -64,18 +69,18 @@ module DeployGate
64
69
  end
65
70
  end
66
71
 
67
- def build!(bundle_id, args, options)
68
- app = DeployGate::Xcode::MemberCenters::App.new(bundle_id)
72
+ def build!(bundle_id, member_center, args, options)
73
+ app = DeployGate::Xcode::MemberCenters::App.new(bundle_id, member_center)
69
74
  app.create! unless app.created?
70
75
 
71
- DeployGate::Xcode::MemberCenters::ProvisioningProfile.new(bundle_id).create!
72
- team = DeployGate::Xcode::MemberCenter.instance.team
76
+ DeployGate::Xcode::MemberCenters::ProvisioningProfile.new(bundle_id, member_center).create!
77
+ team = member_center.team
73
78
  DeployGate::Xcode::Export.clean_provisioning_profiles(bundle_id, team)
74
79
 
75
80
  DeployGate::Commands::Deploy::Build.run(args, options)
76
81
  end
77
82
 
78
- def fetch_devices(token, owner, bundle_id)
83
+ def fetch_devices(token, owner, bundle_id, member_center)
79
84
  res = DeployGate::API::V1::Users::App.not_provisioned_udids(token, owner, bundle_id)
80
85
  if res[:error]
81
86
  case res[:message]
@@ -89,21 +94,11 @@ module DeployGate
89
94
  end
90
95
 
91
96
  results = res[:results]
92
- devices = results.map{|r| DeployGate::Xcode::MemberCenters::Device.new(r[:udid], r[:user_name], r[:device_name])}
97
+ devices = results.map{|r| DeployGate::Xcode::MemberCenters::Device.new(r[:udid], r[:user_name], r[:device_name], member_center)}
93
98
 
94
99
  devices
95
100
  end
96
101
 
97
- # @param [String] work_dir
98
- # @param [String] build_configuration
99
- # @return [String]
100
- def bundle_id(work_dir, build_configuration)
101
- root_path = DeployGate::Xcode::Ios.project_root_path(work_dir)
102
- workspaces = DeployGate::Xcode::Ios.find_workspaces(root_path)
103
- analyze = DeployGate::Xcode::Analyze.new(workspaces, build_configuration)
104
- analyze.target_bundle_identifier
105
- end
106
-
107
102
  # @param [Array]
108
103
  # @return [Array]
109
104
  def select_devices(devices)
@@ -38,44 +38,24 @@ module DeployGate
38
38
  analyze = DeployGate::Xcode::Analyze.new(workspaces, build_configuration, target_scheme)
39
39
  target_scheme = analyze.scheme
40
40
 
41
- # TODO: Support export method option (ex: --method adhoc)
42
- codesigning_identity= nil
43
- provisioning_style = analyze.provisioning_style
44
- provisioning_profile_info = nil
45
- if (!over_xcode?(8) && provisioning_style == nil) ||
46
- provisioning_style == DeployGate::Xcode::Analyze::PROVISIONING_STYLE_MANUAL
47
-
48
- # Only run Provisioning Style is Manual or nil
49
- bundle_identifier = analyze.target_bundle_identifier
50
- xcode_provisioning_profile_uuid = analyze.target_xcode_setting_provisioning_profile_uuid
51
- provisioning_team = analyze.provisioning_team
52
- target_provisioning_profile = DeployGate::Xcode::Export.provisioning_profile(
53
- bundle_identifier,
54
- xcode_provisioning_profile_uuid,
55
- provisioning_team
56
- )
57
-
58
- method = DeployGate::Xcode::Export.method(target_provisioning_profile)
59
- codesigning_identity = DeployGate::Xcode::Export.codesigning_identity(target_provisioning_profile)
60
-
61
- profile = FastlaneCore::ProvisioningProfile.parse(target_provisioning_profile)
62
- provisioning_profile_info = {
63
- provisioningProfiles: {
64
- "#{bundle_identifier}" => profile['Name']
65
- }
66
- }
67
- else
68
- method = select_method
41
+ code_sign_identity = nil
42
+ project_profile_info = nil
43
+ allow_provisioning_updates = true
44
+ if analyze.code_sign_style == Xcode::Analyze::PROVISIONING_STYLE_MANUAL
45
+ code_sign_identity = analyze.code_sign_identity
46
+ project_profile_info = analyze.project_profile_info
69
47
  end
70
48
 
49
+ method = Xcode::Export.method(analyze.target_provisioning_profile) || select_method
50
+
71
51
  ipa_path = DeployGate::Xcode::Ios.build(
72
52
  analyze,
73
53
  target_scheme,
74
- codesigning_identity,
75
- provisioning_profile_info,
54
+ code_sign_identity,
55
+ project_profile_info,
76
56
  build_configuration,
77
57
  method,
78
- over_xcode?(9) && codesigning_identity.nil?
58
+ allow_provisioning_updates
79
59
  )
80
60
  Push.upload([ipa_path], options)
81
61
  end
@@ -1,10 +1,10 @@
1
1
  module DeployGate
2
2
  class Deploy
3
- class NotLoginError < DeployGate::NotIssueError
3
+ class NotLoginError < DeployGate::RavenIgnoreException
4
4
  end
5
- class NotFileExistError < DeployGate::NotIssueError
5
+ class NotFileExistError < DeployGate::RavenIgnoreException
6
6
  end
7
- class UploadError < DeployGate::NotIssueError
7
+ class UploadError < DeployGate::RavenIgnoreException
8
8
  end
9
9
 
10
10
  class << self
@@ -0,0 +1,4 @@
1
+ module DeployGate
2
+ class RavenIgnoreException < StandardError
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  module DeployGate
2
2
  class Session
3
- class LoginError < DeployGate::NotIssueError
3
+ class LoginError < DeployGate::RavenIgnoreException
4
4
  end
5
5
 
6
6
  attr_reader :name, :token
@@ -1,3 +1,3 @@
1
1
  module DeployGate
2
- VERSION = '0.6.7'
2
+ VERSION = '0.8.2'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module DeployGate
2
2
  module Xcode
3
3
  class Analyze
4
- attr_reader :workspaces, :scheme_workspace, :build_workspace, :scheme
4
+ attr_reader :workspaces, :scheme_workspace, :build_workspace, :scheme, :xcodeproj
5
5
 
6
6
  BASE_WORK_DIR_NAME = 'project.xcworkspace'
7
7
  DEFAULT_BUILD_CONFIGURATION = 'Release'
@@ -9,7 +9,7 @@ module DeployGate
9
9
  PROVISIONING_STYLE_AUTOMATIC = 'Automatic'
10
10
  PROVISIONING_STYLE_MANUAL = 'Manual'
11
11
 
12
- class BundleIdentifierDifferentError < DeployGate::NotIssueError
12
+ class BundleIdentifierDifferentError < DeployGate::RavenIgnoreException
13
13
  end
14
14
 
15
15
  # @param [Array] workspaces
@@ -23,153 +23,93 @@ module DeployGate
23
23
  @build_workspace = find_build_workspace(workspaces)
24
24
  @xcodeproj = File.dirname(@scheme_workspace)
25
25
 
26
- config = FastlaneCore::Configuration.create(Gym::Options.available_options, { workspace: @scheme_workspace })
27
- project = FastlaneCore::Project.new(config)
26
+ config = FastlaneCore::Configuration.create(Gym::Options.available_options, { project: @xcodeproj })
27
+ Gym.config = config
28
+ @project = FastlaneCore::Project.new(config)
28
29
 
29
- if project.schemes.length > 1 && target_scheme && project.schemes.include?(target_scheme)
30
- project.options[:scheme] = target_scheme
30
+ if @project.schemes.length > 1 && target_scheme && @project.schemes.include?(target_scheme)
31
+ @project.options[:scheme] = target_scheme
31
32
  else
32
- project.select_scheme
33
+ @project.select_scheme
33
34
  end
34
- @scheme = project.options[:scheme]
35
+ @scheme = @project.options[:scheme]
35
36
  end
36
37
 
37
- # Support Xcode7 more
38
- # @return [String]
39
- def target_bundle_identifier
40
- begin
41
- product_name = target_product_name
42
- product_bundle_identifier = target_build_configration.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
43
- product_bundle_identifier = convert_bundle_identifier(product_bundle_identifier)
44
-
45
- info_plist_file_path = target_build_configration.build_settings['INFOPLIST_FILE']
46
- root_path = DeployGate::Xcode::Ios.project_root_path(@scheme_workspace)
47
- plist_bundle_identifier =
48
- File.open(File.join(root_path, info_plist_file_path)) do |file|
49
- plist = Plist.parse_xml file.read
50
- plist['CFBundleIdentifier']
51
- end
52
- plist_bundle_identifier = convert_bundle_identifier(plist_bundle_identifier)
53
-
54
- bundle_identifier = if plist_bundle_identifier.blank?
55
- product_bundle_identifier
56
- else
57
- plist_bundle_identifier
58
- end
59
- bundle_identifier.gsub!(/\$\(PRODUCT_NAME:.+\)/, product_name)
60
- rescue BundleIdentifierDifferentError => e
61
- raise e
62
- rescue => e
63
- cli = HighLine.new
64
- puts I18n.t('xcode.analyze.target_bundle_identifier.prompt')
65
- bundle_identifier = cli.ask(I18n.t('xcode.analyze.target_bundle_identifier.ask')) { |q| q.validate = /^(\w+)\.(\w+).*\w$/ }
38
+ def code_sign_style
39
+ style = nil
40
+ resolve_build_configuration do |build_configuration, target|
41
+ style = build_configuration.resolve_build_setting("CODE_SIGN_STYLE", target)
66
42
  end
67
43
 
68
- bundle_identifier
44
+ style
69
45
  end
70
46
 
71
- # @param [String] bundle_identifier
72
- # @return [String]
73
- def convert_bundle_identifier(bundle_identifier)
74
- new_bundle_identifier = bundle_identifier.gsub(/\$\(([^\)]+)\)|\${([^}]+)}/) {
75
- custom_id = $1 || $2
76
- if custom_id == 'TARGET_NAME'
77
- target_project_setting.name
78
- else
79
- target_build_configration.build_settings[custom_id]
80
- end
81
- }
82
- # bail out if the result identical to the original
83
- return bundle_identifier if new_bundle_identifier == bundle_identifier
47
+ def code_sign_identity
48
+ identity = nil
49
+ resolve_build_configuration do |build_configuration, target|
50
+ identity = build_configuration.resolve_build_setting("CODE_SIGN_IDENTITY", target)
51
+ end
84
52
 
85
- convert_bundle_identifier(new_bundle_identifier)
53
+ identity
86
54
  end
87
55
 
56
+ # TODO: Need to support UDID additions for watchOS and App Extension
88
57
  # @return [String]
89
- def target_xcode_setting_provisioning_profile_uuid
90
- uuid = target_build_configration.build_settings['PROVISIONING_PROFILE']
91
- UUID.validate(uuid) ? uuid : nil
92
- end
93
-
94
- def provisioning_style
95
- target = target_provisioning_info
96
- build_settings = target_build_configration.build_settings
97
-
98
- style = PROVISIONING_STYLE_MANUAL
99
- if target
100
- # Manual or Automatic or nil (Xcode7 below)
101
- begin
102
- style = target['ProvisioningStyle'] || build_settings['CODE_SIGN_STYLE']
103
- rescue
104
- # Not catch error
105
- end
58
+ def target_bundle_identifier
59
+ bundle_identifier = nil
60
+ resolve_build_configuration do |build_configuration, target|
61
+ bundle_identifier = build_configuration.resolve_build_setting("PRODUCT_BUNDLE_IDENTIFIER", target)
106
62
  end
107
63
 
108
- style
64
+ bundle_identifier
109
65
  end
110
66
 
111
- def provisioning_team
112
- target = target_provisioning_info
113
-
67
+ def developer_team
114
68
  team = nil
115
- if target
116
- begin
117
- team = target['DevelopmentTeam']
118
- rescue
119
- # Not catch error
120
- end
69
+ resolve_build_configuration do |build_configuration, target|
70
+ team = build_configuration.resolve_build_setting("DEVELOPMENT_TEAM", target)
121
71
  end
122
72
 
123
73
  team
124
74
  end
125
75
 
126
- private
127
-
128
- def target_provisioning_info
129
- main_target = target_project_setting
130
- main_target_uuid = main_target && main_target.uuid
131
-
132
- target = nil
133
- if main_target_uuid
134
- begin
135
- target = target_project.root_object.attributes['TargetAttributes'][main_target_uuid]
136
- rescue
137
- # Not catch error
138
- end
139
- end
76
+ def project_profile_info
77
+ gym = Gym::CodeSigningMapping.new(project: @project)
140
78
 
141
- target
79
+ {
80
+ provisioningProfiles: gym.detect_project_profile_mapping
81
+ }
142
82
  end
143
83
 
144
- def target_build_configration
145
- target_project_setting.build_configuration_list.build_configurations.reject{|conf| conf.name != @build_configuration}.first
146
- end
84
+ def target_provisioning_profile
85
+ gym = Gym::CodeSigningMapping.new(project: @project)
86
+ bundle_id = target_bundle_identifier
147
87
 
148
- def target_product_name
149
- target_project_setting.product_name
88
+ Xcode::Export.provisioning_profile(bundle_id, nil, developer_team, gym.merge_profile_mapping[bundle_id.to_sym])
150
89
  end
151
90
 
152
- def target_project_setting
153
- scheme_file = find_xcschemes
154
- xs = Xcodeproj::XCScheme.new(scheme_file)
155
- target_name = xs.profile_action.buildable_product_runnable.buildable_reference.target_name
91
+ private
156
92
 
157
- target_project.native_targets.reject{|target| target.name != target_name}.first
158
- end
93
+ def resolve_build_configuration(&block)
94
+ gym = Gym::CodeSigningMapping.new(project: @project)
95
+ specified_configuration = gym.detect_configuration_for_archive
159
96
 
160
- def target_project
161
- Xcodeproj::Project.open(@xcodeproj)
162
- end
97
+ Xcodeproj::Project.open(@xcodeproj).targets.each do |target|
98
+ target.build_configuration_list.build_configurations.each do |build_configuration|
99
+ # Used the following code as an example
100
+ # https://github.com/fastlane/fastlane/blob/2.148.1/gym/lib/gym/code_signing_mapping.rb#L138
101
+ current = build_configuration.build_settings
102
+ next if gym.test_target?(current)
103
+ sdk_root = build_configuration.resolve_build_setting("SDKROOT", target)
104
+ next unless gym.same_platform?(sdk_root)
105
+ next unless specified_configuration == build_configuration.name
163
106
 
164
- def find_xcschemes
165
- shared_schemes = Dir[File.join(@xcodeproj, 'xcshareddata', 'xcschemes', '*.xcscheme')].reject do |scheme|
166
- @scheme != File.basename(scheme, '.xcscheme')
167
- end
168
- user_schemes = Dir[File.join(@xcodeproj, 'xcuserdata', '*.xcuserdatad', 'xcschemes', '*.xcscheme')].reject do |scheme|
169
- @scheme != File.basename(scheme, '.xcscheme')
170
- end
107
+ # If SKIP_INSTALL is true, it is an app extension or watch app
108
+ next if current["SKIP_INSTALL"]
171
109
 
172
- shared_schemes.concat(user_schemes).first
110
+ block.call(build_configuration, target)
111
+ end
112
+ end
173
113
  end
174
114
 
175
115
  # @param [Array] workspaces
@@ -12,12 +12,12 @@ module DeployGate
12
12
  # @param [String] uuid
13
13
  # @param [String] provisioning_team
14
14
  # @return [String]
15
- def provisioning_profile(bundle_identifier, uuid = nil, provisioning_team = nil)
16
- local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid, provisioning_team)
15
+ def provisioning_profile(bundle_identifier, uuid = nil, provisioning_team = nil, specifier_name = nil)
16
+ local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid, provisioning_team, specifier_name)
17
17
 
18
18
  case local_teams.teams_count
19
19
  when 0
20
- target_provisioning_profile = create_provisioning(bundle_identifier, uuid)
20
+ target_provisioning_profile = create_provisioning(bundle_identifier, uuid, provisioning_team)
21
21
  when 1
22
22
  target_provisioning_profile = select_profile(local_teams.first_team_profile_paths)
23
23
  else
@@ -32,12 +32,13 @@ module DeployGate
32
32
  # @param [String] uuid
33
33
  # @param [String] provisioning_team
34
34
  # @return [LocalTeams]
35
- def find_local_data(bundle_identifier, uuid = nil, provisioning_team = nil)
35
+ def find_local_data(bundle_identifier, uuid = nil, provisioning_team = nil, specifier_name = nil)
36
36
  local_teams = LocalTeams.new
37
37
 
38
38
  profile_paths = load_profile_paths
39
39
  profiles = profile_paths.map{|p| profile_to_plist(p)}
40
40
  profiles.reject! {|profile| profile['UUID'] != uuid} unless uuid.nil?
41
+ profiles.reject! {|profile| profile['Name'] != specifier_name} unless specifier_name.nil?
41
42
 
42
43
  profiles.each do |profile|
43
44
  next if DateTime.now >= profile['ExpirationDate'] || !installed_certificate?(profile['Path'])
@@ -79,7 +80,7 @@ module DeployGate
79
80
  certificates = installed_certificates()
80
81
  ids = []
81
82
  certificates.each do |current|
82
- next unless current.match(/iPhone Distribution:/)
83
+ next unless current.match(/iPhone Distribution:/) || current.match(/Apple Distribution:/)
83
84
  begin
84
85
  (ids << current.match(/.*\) (.*) \".*/)[1])
85
86
  rescue
@@ -91,12 +92,12 @@ module DeployGate
91
92
  end
92
93
 
93
94
  # @return [Array]
94
- def installed_distribution_conflicting_certificates
95
+ def installed_distribution_conflicting_certificates_by(distribution_name)
95
96
  certificates = installed_certificates()
96
97
  names = []
97
98
  certificates.each do |current|
98
99
  begin
99
- names << current.match(/(iPhone Distribution:.*)/)[1]
100
+ names << current.match(/(#{distribution_name}:.*)/)[1]
100
101
  rescue
101
102
  end
102
103
  end
@@ -105,7 +106,7 @@ module DeployGate
105
106
  conflicting_certificates = []
106
107
  certificates.each do |current|
107
108
  begin
108
- name = current.match(/(iPhone Distribution:.*)/)[1]
109
+ name = current.match(/(#{distribution_name}:.*)/)[1]
109
110
  next unless conflicting_names.include?(name)
110
111
  conflicting_certificates << current
111
112
  rescue
@@ -201,9 +202,10 @@ module DeployGate
201
202
  end
202
203
  end
203
204
 
204
- def create_provisioning(identifier, uuid)
205
- app = MemberCenters::App.new(identifier)
206
- provisioning_prifile = MemberCenters::ProvisioningProfile.new(identifier)
205
+ def create_provisioning(identifier, uuid, team_id)
206
+ member_center = Xcode::MemberCenter.new(team_id)
207
+ app = MemberCenters::App.new(identifier, member_center)
208
+ provisioning_prifile = MemberCenters::ProvisioningProfile.new(identifier, member_center)
207
209
 
208
210
  begin
209
211
  unless app.created?
@@ -253,12 +255,16 @@ module DeployGate
253
255
  exit
254
256
  end
255
257
 
256
- conflicting_certificates = installed_distribution_conflicting_certificates
257
- if conflicting_certificates.count > 0
258
+ iphone_conflicting_certificates = installed_distribution_conflicting_certificates_by('iPhone Distribution')
259
+ apple_conflicting_certificates = installed_distribution_conflicting_certificates_by('Apple Distribution')
260
+ if iphone_conflicting_certificates.count > 0 || apple_conflicting_certificates.count > 0
258
261
  puts HighLine.color(I18n.t('xcode.export.check_local_certificates.conflict_certificate.error_message'), HighLine::RED)
259
262
  puts ''
260
263
  puts I18n.t('xcode.export.check_local_certificates.conflict_certificate.note')
261
- conflicting_certificates.each do |certificate|
264
+ iphone_conflicting_certificates.each do |certificate|
265
+ puts certificate
266
+ end
267
+ apple_conflicting_certificates.each do |certificate|
262
268
  puts certificate
263
269
  end
264
270
  puts ""