Skip to content

Commit c46b8bd

Browse files
committed
Add provisioning actions
Adds two actions: add_development_certificates_to_provisioning_profiles ========== Adds all team member’s development certificates to the specified provisioning profiles add_devices_to_provisioning_profiles ========== Adds all iOS devices to the specified provisioning profiles
1 parent 0eaa4da commit c46b8bd

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
module Fastlane
2+
module Actions
3+
class AddDevelopmentCertificatesToProvisioningProfilesAction < Action
4+
def self.run(params)
5+
require 'spaceship'
6+
7+
Spaceship.login
8+
Spaceship.select_team(team_id: params[:team_id])
9+
10+
all_certificates = Spaceship.certificate.all(mac: false).select { |certificate|
11+
certificate.owner_type == 'teamMember'
12+
}
13+
14+
params[:app_identifier].each { |identifier|
15+
Spaceship.provisioning_profile.find_by_bundle_id(bundle_id: identifier)
16+
.select { |profile|
17+
profile.kind_of? Spaceship::Portal::ProvisioningProfile::Development
18+
}
19+
.tap { |profiles|
20+
UI.important "Warning: Unable to find any profiles associated with #{identifier}" unless profiles.length > 0
21+
}
22+
.each { |profile|
23+
profile.certificates = all_certificates
24+
profile.update!
25+
UI.success "Applied #{all_certificates.length} certificates to #{profile.name}"
26+
}
27+
}
28+
29+
end
30+
31+
#####################################################
32+
# @!group Documentation
33+
#####################################################
34+
35+
def self.description
36+
"Add dev certificates to provisioning profiles"
37+
end
38+
39+
def self.details
40+
"Add all team member's development certificates to profiles associated with the provided bundle identifiers"
41+
end
42+
43+
def self.available_options
44+
[
45+
FastlaneCore::ConfigItem.new(key: :app_identifier,
46+
description: "List of App Identifiers that should contain the new device identifier",
47+
is_string: false,
48+
verify_block: proc do |value|
49+
UI.user_error!("You must provide an array of bundle identifiers in `app_identifier`") unless not value.empty?
50+
end),
51+
FastlaneCore::ConfigItem.new(key: :team_id,
52+
description: "The team_id for the provisioning profiles",
53+
is_string: true,
54+
verify_block: proc do |value|
55+
UI.user_error!("You must provide a team ID in `team_id`") unless (value and not value.empty?)
56+
end),
57+
]
58+
end
59+
60+
def self.output
61+
# This lane doesn't provide variables that other lanes can consume.
62+
end
63+
64+
def self.return_value
65+
# If your method provides a return value, you can describe here what it does
66+
end
67+
68+
def self.authors
69+
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
70+
["jkmassel"]
71+
end
72+
73+
def self.is_supported?(platform)
74+
platform == :ios
75+
end
76+
end
77+
end
78+
end
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
module Fastlane
2+
module Actions
3+
class AddAllDevicesToProvisioningProfilesAction < Action
4+
def self.run(params)
5+
require 'spaceship'
6+
7+
Spaceship.login
8+
Spaceship.select_team(team_id: params[:team_id])
9+
10+
devices = Spaceship.device.all_ios_profile_devices
11+
12+
params[:app_identifier].each { |identifier|
13+
Spaceship.provisioning_profile.find_by_bundle_id(bundle_id: identifier)
14+
.select { |profile|
15+
profile.kind_of? Spaceship::Portal::ProvisioningProfile::Development
16+
}
17+
.tap { |profiles|
18+
UI.important "Warning: Unable to find any profiles associated with #{identifier}" unless profiles.length > 0
19+
}
20+
.each { |profile|
21+
profile.devices = devices
22+
profile.update!
23+
UI.success "Applied #{devices.length} devices to #{profile.name}"
24+
}
25+
}
26+
end
27+
28+
#####################################################
29+
# @!group Documentation
30+
#####################################################
31+
32+
def self.description
33+
"Add devices to provisioning profiles"
34+
end
35+
36+
def self.details
37+
"Add all iOS devices to any profiles associated with the provided bundle identifiers"
38+
end
39+
40+
def self.available_options
41+
[
42+
FastlaneCore::ConfigItem.new(
43+
key: :app_identifier,
44+
description: "List of App Identifiers that should contain the new device identifier",
45+
is_string: false,
46+
verify_block: proc do |value|
47+
UI.user_error!("You must provide an array of bundle identifiers in `app_identifier`") unless not value.empty?
48+
end
49+
),
50+
FastlaneCore::ConfigItem.new(
51+
key: :team_id,
52+
description: "The team_id for the provisioning profiles",
53+
is_string: true,
54+
verify_block: proc do |value|
55+
UI.user_error!("You must provide a team ID in `team_id`") unless (value and not value.empty?)
56+
end
57+
),
58+
]
59+
end
60+
61+
def self.output
62+
# This lane doesn't provide variables that other lanes can consume.
63+
end
64+
65+
def self.return_value
66+
# If your method provides a return value, you can describe here what it does
67+
end
68+
69+
def self.authors
70+
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
71+
["jkmassel"]
72+
end
73+
74+
def self.is_supported?(platform)
75+
platform == :ios
76+
end
77+
end
78+
end
79+
end

0 commit comments

Comments
 (0)