From 9a80088d1030139105cd10987fcab558b47451a6 Mon Sep 17 00:00:00 2001 From: henteko Date: Thu, 21 May 2020 18:51:05 +0900 Subject: [PATCH 01/10] Supported Apple Distribution Certificate --- config/locales/en.yml | 6 +++--- lib/deploygate/xcode/export.rb | 18 +++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index eaa5168..4d9fc92 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -142,16 +142,16 @@ en: choice: '%{team_name} %{team_id}' check_local_certificates: not_local_install_certificate: - error_message: 'Error: No applicable iPhone Distribution certificate found on your Mac.' + error_message: 'Error: No applicable iPhone Distribution or Apple Distribution certificate found on your Mac.' note: | - No "iPhone Distribution" certificate and/or corresponding private key installed locally. + No "iPhone Distribution" or "Apple Distribution" certificate and/or corresponding private key installed locally. To sign your application code, make sure you have installed them and available in your Keychain. See also: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html conflict_certificate: error_message: 'Error: Too many certificates found.' note: | - You have more than one "iPhone Distribution" certificate installed on your Mac. + You have more than one "iPhone Distribution" or "Apple Distribution" certificate installed on your Mac. Please remove other unnecessary certificates from your Keychain. clean_provisioning_profiles: start: 'Cleaning local Provisioning Profiles...' diff --git a/lib/deploygate/xcode/export.rb b/lib/deploygate/xcode/export.rb index a237d1f..e18bac1 100644 --- a/lib/deploygate/xcode/export.rb +++ b/lib/deploygate/xcode/export.rb @@ -80,7 +80,7 @@ def installed_distribution_certificate_ids certificates = installed_certificates() ids = [] certificates.each do |current| - next unless current.match(/iPhone Distribution:/) + next unless current.match(/iPhone Distribution:/) || current.match(/Apple Distribution:/) begin (ids << current.match(/.*\) (.*) \".*/)[1]) rescue @@ -92,12 +92,12 @@ def installed_distribution_certificate_ids end # @return [Array] - def installed_distribution_conflicting_certificates + def installed_distribution_conflicting_certificates_by(distribution_name) certificates = installed_certificates() names = [] certificates.each do |current| begin - names << current.match(/(iPhone Distribution:.*)/)[1] + names << current.match(/(#{distribution_name}:.*)/)[1] rescue end end @@ -106,7 +106,7 @@ def installed_distribution_conflicting_certificates conflicting_certificates = [] certificates.each do |current| begin - name = current.match(/(iPhone Distribution:.*)/)[1] + name = current.match(/(#{distribution_name}:.*)/)[1] next unless conflicting_names.include?(name) conflicting_certificates << current rescue @@ -255,12 +255,16 @@ def check_local_certificates exit end - conflicting_certificates = installed_distribution_conflicting_certificates - if conflicting_certificates.count > 0 + iphone_conflicting_certificates = installed_distribution_conflicting_certificates_by('iPhone Distribution') + apple_conflicting_certificates = installed_distribution_conflicting_certificates_by('Apple Distribution') + if iphone_conflicting_certificates.count > 0 || apple_conflicting_certificates.count > 0 puts HighLine.color(I18n.t('xcode.export.check_local_certificates.conflict_certificate.error_message'), HighLine::RED) puts '' puts I18n.t('xcode.export.check_local_certificates.conflict_certificate.note') - conflicting_certificates.each do |certificate| + iphone_conflicting_certificates.each do |certificate| + puts certificate + end + apple_conflicting_certificates.each do |certificate| puts certificate end puts "" From 7625799ffa37f758a65400e797e04a5afcc82b3a Mon Sep 17 00:00:00 2001 From: henteko Date: Thu, 21 May 2020 18:58:26 +0900 Subject: [PATCH 02/10] fixed tests --- spec/deploygate/xcode/export_spec.rb | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/spec/deploygate/xcode/export_spec.rb b/spec/deploygate/xcode/export_spec.rb index 5f610aa..0303c52 100644 --- a/spec/deploygate/xcode/export_spec.rb +++ b/spec/deploygate/xcode/export_spec.rb @@ -61,6 +61,7 @@ before do @distribution_certificate_id = 'distribution_certificate_id' @distribution_certificate = " 1) #{@distribution_certificate_id} \"iPhone Distribution: DeployGate Inc.\"" + @apple_distribution_certificate = " 1) #{@distribution_certificate_id} \"Apple Distribution: DeployGate Inc.\"" @not_distribution_certificate = " 1) xxxxxxxxxxxxxx \"iPhone Developer: DeployGate Inc.\"" end it "not installed distribution certificate" do @@ -74,23 +75,44 @@ ids = DeployGate::Xcode::Export.installed_distribution_certificate_ids expect(ids).to eql([@distribution_certificate_id]) end + + it "installed apple distribution certificate" do + allow(DeployGate::Xcode::Export).to receive(:installed_certificates).and_return([@apple_distribution_certificate, @not_distribution_certificate]) + + ids = DeployGate::Xcode::Export.installed_distribution_certificate_ids + expect(ids).to eql([@distribution_certificate_id]) + end end - describe "#installed_distribution_conflicting_certificates" do + describe "#installed_distribution_conflicting_certificates_by" do before do @distribution_certificate = " 1) xxxxxxxxxx \"iPhone Distribution: DeployGate Inc.\"" @distribution_certificate2 = " 2) yyyyyyyyyyyy \"iPhone Distribution: DeployGate Inc.\"" @distribution_certificate3 = " 2) yyyyyyyyyyyy \"iPhone Distribution: DeployGate Inc2.\"" + + @apple_distribution_certificate = " 1) xxxxxxxxxxx \"Apple Distribution: DeployGate Inc.\"" + @apple_distribution_certificate2 = " 2) yyyyyyyyyyyy \"Apple Distribution: DeployGate Inc.\"" + @apple_distribution_certificate3 = " 2) yyyyyyyyyyyy \"Apple Distribution: DeployGate Inc2.\"" end it "conflicting" do allow(DeployGate::Xcode::Export).to receive(:installed_certificates).and_return([@distribution_certificate, @distribution_certificate2]) - expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates.count).to eql 2 + expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates_by('iPhone Distribution').count).to eql 2 + end + + it "conflicting by apple" do + allow(DeployGate::Xcode::Export).to receive(:installed_certificates).and_return([@apple_distribution_certificate, @apple_distribution_certificate2]) + expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates_by('Apple Distribution').count).to eql 2 end it "not conflicting" do allow(DeployGate::Xcode::Export).to receive(:installed_certificates).and_return([@distribution_certificate, @distribution_certificate3]) - expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates.count).to eql 0 + expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates_by('iPhone Distribution').count).to eql 0 + end + + it "not conflicting by apple" do + allow(DeployGate::Xcode::Export).to receive(:installed_certificates).and_return([@apple_distribution_certificate, @apple_distribution_certificate3]) + expect(DeployGate::Xcode::Export.installed_distribution_conflicting_certificates_by('Apple Distribution').count).to eql 0 end end end From f1b5d3caa399bf21ebd1612dd1b572ce817029ed Mon Sep 17 00:00:00 2001 From: henteko Date: Thu, 21 May 2020 19:02:52 +0900 Subject: [PATCH 03/10] Specify the RVM at deploy time. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e161942..9c5b9ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,5 +20,6 @@ deploy: on: tags: true repo: DeployGate/deploygate-cli + rvm: 2.4 after_deploy: - 'curl -X POST --data-urlencode "payload={\"text\": \"Released a deploygate gem in \"}" $SLACK_URL' From 4d11cd2a575f91cc3e344eb9b09e71e099800495 Mon Sep 17 00:00:00 2001 From: henteko Date: Thu, 21 May 2020 19:03:28 +0900 Subject: [PATCH 04/10] bump up --- lib/deploygate/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deploygate/version.rb b/lib/deploygate/version.rb index a43c175..79648fd 100644 --- a/lib/deploygate/version.rb +++ b/lib/deploygate/version.rb @@ -1,3 +1,3 @@ module DeployGate - VERSION = '0.8.0' + VERSION = '0.8.1' end From d853675a6820b5c0249c420636918d1cd6ae045f Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 12:19:27 +0900 Subject: [PATCH 05/10] fixed resolve build configuration for test targets --- lib/deploygate/xcode/analyze.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index bc9f2e1..471032b 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -96,7 +96,14 @@ def resolve_build_configuration(&block) Xcodeproj::Project.open(@xcodeproj).targets.each do |target| target.build_configuration_list.build_configurations.each do |build_configuration| - next if build_configuration.name != specified_configuration + # Used the following code as an example + # https://github.com/fastlane/fastlane/blob/master/gym/lib/gym/code_signing_mapping.rb#L138 + current = build_configuration.build_settings + next if gym.test_target?(current) + sdk_root = build_configuration.resolve_build_setting("SDKROOT", target) + next unless gym.same_platform?(sdk_root) + next unless specified_configuration == build_configuration.name + block.call(build_configuration, target) end end From 4dd1f45a6eb0d8f2c1c76156e9d49a6662a9941c Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 13:17:48 +0900 Subject: [PATCH 06/10] change example url --- lib/deploygate/xcode/analyze.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index 471032b..55a0cfe 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -97,7 +97,7 @@ def resolve_build_configuration(&block) Xcodeproj::Project.open(@xcodeproj).targets.each do |target| target.build_configuration_list.build_configurations.each do |build_configuration| # Used the following code as an example - # https://github.com/fastlane/fastlane/blob/master/gym/lib/gym/code_signing_mapping.rb#L138 + # https://github.com/fastlane/fastlane/blob/2.148.1/gym/lib/gym/code_signing_mapping.rb#L138 current = build_configuration.build_settings next if gym.test_target?(current) sdk_root = build_configuration.resolve_build_setting("SDKROOT", target) From 2be6c26dccf69d9e1446a6c4816c7e5bad374f03 Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 14:18:28 +0900 Subject: [PATCH 07/10] change check certificate type --- .../xcode/member_centers/provisioning_profile.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/deploygate/xcode/member_centers/provisioning_profile.rb b/lib/deploygate/xcode/member_centers/provisioning_profile.rb index 1d074f9..b95e36e 100644 --- a/lib/deploygate/xcode/member_centers/provisioning_profile.rb +++ b/lib/deploygate/xcode/member_centers/provisioning_profile.rb @@ -35,16 +35,22 @@ def create!(uuid = nil) # @return [Array] def all_create - if @member_center.adhoc? - prod_certs = @member_center.launcher.certificate.production.all - else - prod_certs = @member_center.launcher.certificate.all.reject{|cert| cert.class != Spaceship::Portal::Certificate::InHouse} - end + prod_certs = if @member_center.adhoc? + @member_center.launcher.certificate.all.select{|cert| + cert.class == Spaceship::Portal::Certificate::Production || + cert.class == Spaceship::Portal::Certificate::AppleDistribution + } + else + @member_center.launcher.certificate.all.select{|cert| + cert.class == Spaceship::Portal::Certificate::InHouse + } + end # check local install certificate FileUtils.mkdir_p(CERTIFICATE_OUTPUT_PATH) distribution_cert_ids = [] prod_certs.each do |cert| + next if cert.expires < Time.now path = File.join(CERTIFICATE_OUTPUT_PATH, "#{cert.id}.cer") raw_data = cert.download_raw File.write(path, raw_data) From b682b662b5ad5d2827a3baeec58b58cf370dbdbd Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 14:19:36 +0900 Subject: [PATCH 08/10] update error message --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 4d9fc92..1cdad93 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -171,5 +171,5 @@ en: Note: Your password will be stored to your Keychain and never be sent to DeployGate. email: 'Email: ' provisioning_profile: - not_installed_certificate_error: 'No iPhone Distribution Certificate associated with private key was found in local Keychain' + not_installed_certificate_error: 'No iPhone Distribution or Apple Distribution Certificate associated with private key was found in local Keychain' not_exist_uuid_provisioning_profile_error: 'No provisioning profile found for the specified UUID (%{uuid})' From 94d48fd6ddc51cf6a2c339666dab6c0a834f2890 Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 17:58:39 +0900 Subject: [PATCH 09/10] Check the SKIP_INSTALL in the build settings --- lib/deploygate/xcode/analyze.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index 55a0cfe..83a0860 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -104,6 +104,9 @@ def resolve_build_configuration(&block) next unless gym.same_platform?(sdk_root) next unless specified_configuration == build_configuration.name + # TODO: Need to support UDID additions for watchOS and App Extension + next if current["SKIP_INSTALL"] + block.call(build_configuration, target) end end From b8043eb55da8c96133bf10dc58a3ab135e88ebe5 Mon Sep 17 00:00:00 2001 From: henteko Date: Fri, 22 May 2020 18:29:14 +0900 Subject: [PATCH 10/10] change todo comment --- lib/deploygate/xcode/analyze.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index 83a0860..50dc857 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -53,7 +53,7 @@ def code_sign_identity identity end - # Support Xcode7 more + # TODO: Need to support UDID additions for watchOS and App Extension # @return [String] def target_bundle_identifier bundle_identifier = nil @@ -104,7 +104,7 @@ def resolve_build_configuration(&block) next unless gym.same_platform?(sdk_root) next unless specified_configuration == build_configuration.name - # TODO: Need to support UDID additions for watchOS and App Extension + # If SKIP_INSTALL is true, it is an app extension or watch app next if current["SKIP_INSTALL"] block.call(build_configuration, target)