deploygate 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +4 -0
- data/.travis.yml +4 -4
- data/README.md +3 -3
- data/lib/deploygate/android/gradle_deploy.rb +95 -0
- data/lib/deploygate/android/gradle_plugin_installer.rb +101 -0
- data/lib/deploygate/android/gradle_project.rb +14 -0
- data/lib/deploygate/commands/deploy/build.rb +15 -154
- data/lib/deploygate/{build.rb → project.rb} +3 -3
- data/lib/deploygate/version.rb +1 -1
- data/lib/deploygate/xcode/analyze.rb +116 -0
- data/lib/deploygate/xcode/export.rb +281 -0
- data/lib/deploygate/{builds → xcode}/ios.rb +13 -5
- data/lib/deploygate/xcode/member_center.rb +52 -0
- data/lib/deploygate/xcode/member_centers/app.rb +35 -0
- data/lib/deploygate/xcode/member_centers/provisioning_profile.rb +99 -0
- data/lib/deploygate.rb +14 -5
- data/spec/deploygate/project_spec.rb +39 -0
- data/spec/deploygate/xcode/analyze_spec.rb +3 -0
- data/spec/deploygate/{builds/ios → xcode}/export_spec.rb +21 -21
- data/spec/deploygate/{builds → xcode}/ios_spec.rb +12 -12
- data/spec/deploygate/xcode/member_center_spec.rb +21 -0
- data/spec/deploygate/xcode/member_centers/app_spec.rb +60 -0
- data/spec/deploygate/xcode/member_centers/provisioning_profile_spec.rb +3 -0
- metadata +70 -66
- data/lib/deploygate/builds/ios/analyze.rb +0 -111
- data/lib/deploygate/builds/ios/export.rb +0 -188
- data/lib/deploygate/builds/ios/set_profile.rb +0 -128
- data/spec/deploygate/build_spec.rb +0 -37
- data/spec/deploygate/builds/ios/analyze_spec.rb +0 -3
- data/spec/deploygate/builds/ios/set_profile_spec.rb +0 -3
@@ -1,188 +0,0 @@
|
|
1
|
-
module DeployGate
|
2
|
-
module Builds
|
3
|
-
module Ios
|
4
|
-
class Export
|
5
|
-
AD_HOC = 'ad-hoc'
|
6
|
-
ENTERPRISE = 'enterprise'
|
7
|
-
SUPPORT_EXPORT_METHOD = [AD_HOC, ENTERPRISE]
|
8
|
-
PROFILE_EXTNAME = '.mobileprovision'
|
9
|
-
|
10
|
-
class << self
|
11
|
-
# @param [String] bundle_identifier
|
12
|
-
# @param [String] uuid
|
13
|
-
# @return [Hash]
|
14
|
-
def find_local_data(bundle_identifier, uuid = nil)
|
15
|
-
result_profiles = {}
|
16
|
-
teams = {}
|
17
|
-
profile_paths = load_profile_paths
|
18
|
-
profiles = profile_paths.map{|p| profile_to_plist(p)}
|
19
|
-
profiles.reject! {|profile| profile['UUID'] != uuid} unless uuid.nil?
|
20
|
-
|
21
|
-
profiles.each do |profile|
|
22
|
-
entities = profile['Entitlements']
|
23
|
-
unless entities['get-task-allow']
|
24
|
-
team = entities['com.apple.developer.team-identifier']
|
25
|
-
application_id = entities['application-identifier']
|
26
|
-
application_id.slice!(/^#{team}\./)
|
27
|
-
application_id = '.' + application_id if application_id == '*'
|
28
|
-
if bundle_identifier.match(application_id) &&
|
29
|
-
DateTime.now < profile['ExpirationDate'] &&
|
30
|
-
installed_certificate?(profile['Path'])
|
31
|
-
|
32
|
-
teams[team] = profile['TeamName'] if teams[team].nil?
|
33
|
-
result_profiles[team] = [] if result_profiles[team].nil?
|
34
|
-
result_profiles[team].push(profile['Path'])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
{
|
40
|
-
:teams => teams,
|
41
|
-
:profiles => result_profiles
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
# @param [String] profile_path
|
46
|
-
# @return [Boolean]
|
47
|
-
def installed_certificate?(profile_path)
|
48
|
-
profile = profile_to_plist(profile_path)
|
49
|
-
certs = profile['DeveloperCertificates'].map do |cert|
|
50
|
-
certificate_str = cert.read
|
51
|
-
certificate = OpenSSL::X509::Certificate.new certificate_str
|
52
|
-
id = OpenSSL::Digest::SHA1.new(certificate.to_der).to_s.upcase!
|
53
|
-
installed_distribution_certificate_ids.include?(id)
|
54
|
-
end
|
55
|
-
certs.include?(true)
|
56
|
-
end
|
57
|
-
|
58
|
-
# @return [Array]
|
59
|
-
def installed_distribution_certificate_ids
|
60
|
-
certificates = installed_certificates()
|
61
|
-
ids = []
|
62
|
-
certificates.each do |current|
|
63
|
-
next unless current.match(/iPhone Distribution:/)
|
64
|
-
begin
|
65
|
-
(ids << current.match(/.*\) (.*) \".*/)[1])
|
66
|
-
rescue
|
67
|
-
# the last line does not match
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
ids
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [Array]
|
75
|
-
def installed_distribution_conflicting_certificates
|
76
|
-
certificates = installed_certificates()
|
77
|
-
names = []
|
78
|
-
certificates.each do |current|
|
79
|
-
begin
|
80
|
-
names << current.match(/(iPhone Distribution:.*)/)[1]
|
81
|
-
rescue
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
conflicting_names = names.select{|e| names.index(e) != names.rindex(e)}.uniq
|
86
|
-
conflicting_certificates = []
|
87
|
-
certificates.each do |current|
|
88
|
-
begin
|
89
|
-
name = current.match(/(iPhone Distribution:.*)/)[1]
|
90
|
-
next unless conflicting_names.include?(name)
|
91
|
-
conflicting_certificates << current
|
92
|
-
rescue
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
conflicting_certificates
|
97
|
-
end
|
98
|
-
|
99
|
-
# @return [Array]
|
100
|
-
def installed_certificates
|
101
|
-
available = `security find-identity -v -p codesigning`
|
102
|
-
certificates = []
|
103
|
-
available.split("\n").each do |current|
|
104
|
-
next if current.include? "REVOKED"
|
105
|
-
certificates << current
|
106
|
-
end
|
107
|
-
|
108
|
-
certificates
|
109
|
-
end
|
110
|
-
|
111
|
-
# @param [Array] profile_paths
|
112
|
-
# @return [String]
|
113
|
-
def select_profile(profile_paths)
|
114
|
-
select = nil
|
115
|
-
|
116
|
-
profile_paths.each do |path|
|
117
|
-
select = path if adhoc?(path) && select.nil?
|
118
|
-
select = path if inhouse?(path)
|
119
|
-
end
|
120
|
-
select
|
121
|
-
end
|
122
|
-
|
123
|
-
# @param [String] profile_path
|
124
|
-
# @return [String]
|
125
|
-
def codesigning_identity(profile_path)
|
126
|
-
profile = profile_to_plist(profile_path)
|
127
|
-
identity = nil
|
128
|
-
|
129
|
-
profile['DeveloperCertificates'].each do |cert|
|
130
|
-
certificate_str = cert.read
|
131
|
-
certificate = OpenSSL::X509::Certificate.new certificate_str
|
132
|
-
id = OpenSSL::Digest::SHA1.new(certificate.to_der).to_s.upcase!
|
133
|
-
|
134
|
-
available = `security find-identity -v -p codesigning`
|
135
|
-
available.split("\n").each do |current|
|
136
|
-
next if current.include? "REVOKED"
|
137
|
-
begin
|
138
|
-
search = current.match(/.*\) (.*) \"(.*)\"/)
|
139
|
-
identity = search[2] if id == search[1]
|
140
|
-
rescue
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
identity
|
146
|
-
end
|
147
|
-
|
148
|
-
# @param [String] profile_path
|
149
|
-
# @return [String]
|
150
|
-
def method(profile_path)
|
151
|
-
adhoc?(profile_path) ? AD_HOC : ENTERPRISE
|
152
|
-
end
|
153
|
-
|
154
|
-
# @param [String] profile_path
|
155
|
-
# @return [Boolean]
|
156
|
-
def adhoc?(profile_path)
|
157
|
-
profile = profile_to_plist(profile_path)
|
158
|
-
!profile['Entitlements']['get-task-allow'] && profile['ProvisionsAllDevices'].nil?
|
159
|
-
end
|
160
|
-
|
161
|
-
# @param [String] profile_path
|
162
|
-
# @return [Boolean]
|
163
|
-
def inhouse?(profile_path)
|
164
|
-
profile = profile_to_plist(profile_path)
|
165
|
-
!profile['Entitlements']['get-task-allow'] && !profile['ProvisionsAllDevices'].nil?
|
166
|
-
end
|
167
|
-
|
168
|
-
def load_profile_paths
|
169
|
-
profiles_path = File.expand_path("~") + "/Library/MobileDevice/Provisioning Profiles/*.mobileprovision"
|
170
|
-
Dir[profiles_path]
|
171
|
-
end
|
172
|
-
|
173
|
-
# @param [String] profile_path
|
174
|
-
# @return [Hash]
|
175
|
-
def profile_to_plist(profile_path)
|
176
|
-
File.open(profile_path) do |profile|
|
177
|
-
asn1 = OpenSSL::ASN1.decode(profile.read)
|
178
|
-
plist_str = asn1.value[1].value[0].value[2].value[1].value[0].value
|
179
|
-
plist = Plist.parse_xml plist_str.force_encoding('UTF-8')
|
180
|
-
plist['Path'] = profile_path
|
181
|
-
return plist
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
module DeployGate
|
2
|
-
module Builds
|
3
|
-
module Ios
|
4
|
-
class SetProfile
|
5
|
-
attr_reader :method
|
6
|
-
|
7
|
-
OUTPUT_PATH = '/tmp/dg/provisioning_profile/'
|
8
|
-
CERTIFICATE_OUTPUT_PATH = '/tmp/dg/certificate/'
|
9
|
-
|
10
|
-
# @param [String] username
|
11
|
-
# @param [String] identifier
|
12
|
-
# @return [DeployGate::Builds::Ios::SetProfile]
|
13
|
-
def initialize(username, identifier)
|
14
|
-
@username = username
|
15
|
-
@identifier = identifier
|
16
|
-
Spaceship.login(username)
|
17
|
-
Spaceship.select_team
|
18
|
-
if Spaceship.client.in_house?
|
19
|
-
@method = Export::ENTERPRISE
|
20
|
-
else
|
21
|
-
@method = Export::AD_HOC
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [Boolean]
|
26
|
-
def app_id_create
|
27
|
-
app_created = false
|
28
|
-
Spaceship.app.all.collect do |app|
|
29
|
-
if app.bundle_id == @identifier
|
30
|
-
app_created = true
|
31
|
-
break
|
32
|
-
end
|
33
|
-
end
|
34
|
-
unless app_created
|
35
|
-
Spaceship.app.create!(:bundle_id => @identifier, :name => "#{@identifier.split('.').join(' ')}")
|
36
|
-
return true
|
37
|
-
end
|
38
|
-
|
39
|
-
false
|
40
|
-
end
|
41
|
-
|
42
|
-
# @param [String] uuid
|
43
|
-
# @return [Array]
|
44
|
-
def create_provisioning(uuid)
|
45
|
-
FileUtils.mkdir_p(OUTPUT_PATH)
|
46
|
-
|
47
|
-
if uuid.nil?
|
48
|
-
return install_provisioning
|
49
|
-
else
|
50
|
-
return select_uuid_provisioning(uuid)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def select_uuid_provisioning(uuid)
|
57
|
-
adhoc_profiles = Spaceship.provisioning_profile.ad_hoc.all
|
58
|
-
inhouse_profiles = Spaceship.provisioning_profile.in_house.all
|
59
|
-
|
60
|
-
adhoc_profiles.reject!{|p| p.uuid != uuid}
|
61
|
-
inhouse_profiles.reject!{|p| p.uuid != uuid}
|
62
|
-
select_profile = nil
|
63
|
-
method = nil
|
64
|
-
unless adhoc_profiles.empty?
|
65
|
-
select_profile = adhoc_profiles.first
|
66
|
-
method = Export::AD_HOC
|
67
|
-
end
|
68
|
-
unless inhouse_profiles.empty?
|
69
|
-
select_profile = inhouse_profiles.first
|
70
|
-
method = Export::ENTERPRISE
|
71
|
-
end
|
72
|
-
raise 'Not Xcode selected Provisioning Profile' if select_profile.nil?
|
73
|
-
|
74
|
-
values = {
|
75
|
-
:adhoc => method == Export::AD_HOC ? true : false,
|
76
|
-
:app_identifier => @identifier,
|
77
|
-
:username => @username,
|
78
|
-
:output_path => OUTPUT_PATH,
|
79
|
-
:provisioning_name => select_profile.name,
|
80
|
-
:team_id => Spaceship.client.team_id
|
81
|
-
}
|
82
|
-
v = FastlaneCore::Configuration.create(Sigh::Options.available_options, values)
|
83
|
-
Sigh.config = v
|
84
|
-
download_profile_path = Sigh::Manager.start
|
85
|
-
|
86
|
-
[download_profile_path]
|
87
|
-
end
|
88
|
-
|
89
|
-
def install_provisioning
|
90
|
-
if @method == Export::AD_HOC
|
91
|
-
prod_certs = Spaceship.certificate.production.all
|
92
|
-
else
|
93
|
-
prod_certs = Spaceship.certificate.all.reject{|cert| cert.class != Spaceship::Portal::Certificate::InHouse}
|
94
|
-
end
|
95
|
-
|
96
|
-
# check local install certificate
|
97
|
-
FileUtils.mkdir_p(CERTIFICATE_OUTPUT_PATH)
|
98
|
-
distribution_cert_ids = []
|
99
|
-
prod_certs.each do |cert|
|
100
|
-
path = File.join(CERTIFICATE_OUTPUT_PATH, "#{cert.id}.cer")
|
101
|
-
raw_data = cert.download_raw
|
102
|
-
File.write(path, raw_data)
|
103
|
-
distribution_cert_ids.push(cert.id) if FastlaneCore::CertChecker.installed?(path)
|
104
|
-
end
|
105
|
-
raise 'Not local install certificate' if distribution_cert_ids.empty?
|
106
|
-
|
107
|
-
provisionings = []
|
108
|
-
distribution_cert_ids.each do |cert_id|
|
109
|
-
values = {
|
110
|
-
:adhoc => @method == Export::AD_HOC ? true : false,
|
111
|
-
:app_identifier => @identifier,
|
112
|
-
:username => @username,
|
113
|
-
:output_path => OUTPUT_PATH,
|
114
|
-
:cert_id => cert_id,
|
115
|
-
:team_id => Spaceship.client.team_id
|
116
|
-
}
|
117
|
-
v = FastlaneCore::Configuration.create(Sigh::Options.available_options, values)
|
118
|
-
Sigh.config = v
|
119
|
-
download_profile_path = Sigh::Manager.start
|
120
|
-
provisionings.push(download_profile_path)
|
121
|
-
end
|
122
|
-
|
123
|
-
provisionings
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
describe DeployGate::Build do
|
2
|
-
describe "#ios?" do
|
3
|
-
it "when select workspace" do
|
4
|
-
allow(DeployGate::Builds::Ios).to receive(:ios_root?).and_return(false)
|
5
|
-
allow(DeployGate::Builds::Ios).to receive(:workspace?).and_return(true)
|
6
|
-
allow(DeployGate::Builds::Ios).to receive(:project?).and_return(false)
|
7
|
-
|
8
|
-
result = DeployGate::Build.ios?('path')
|
9
|
-
expect(result).to be_truthy
|
10
|
-
end
|
11
|
-
|
12
|
-
it "when workspaces" do
|
13
|
-
allow(DeployGate::Builds::Ios).to receive(:ios_root?).and_return(false)
|
14
|
-
allow(DeployGate::Builds::Ios).to receive(:workspace?).and_return(false)
|
15
|
-
allow(DeployGate::Builds::Ios).to receive(:project?).and_return(true)
|
16
|
-
|
17
|
-
result = DeployGate::Build.ios?('path')
|
18
|
-
expect(result).to be_truthy
|
19
|
-
end
|
20
|
-
|
21
|
-
it "not ios" do
|
22
|
-
allow(DeployGate::Builds::Ios).to receive(:ios_root?).and_return(false)
|
23
|
-
allow(DeployGate::Builds::Ios).to receive(:workspace?).and_return(false)
|
24
|
-
allow(DeployGate::Builds::Ios).to receive(:project?).and_return(false)
|
25
|
-
|
26
|
-
result = DeployGate::Build.ios?('path')
|
27
|
-
expect(result).to be_falsey
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#android?" do
|
32
|
-
it "android not support" do
|
33
|
-
result = DeployGate::Build.android?('path')
|
34
|
-
expect(result).to be_falsey
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|