cert/lib/cert/runner.rb in fastlane_hotfix-2.165.1 vs cert/lib/cert/runner.rb in fastlane_hotfix-2.187.0
- old
+ new
@@ -18,26 +18,26 @@
UI.success("Successfully installed certificate #{ENV['CER_CERTIFICATE_ID']}")
return ENV["CER_FILE_PATH"]
end
def login
- if api_token
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: Cert.config[:api_key], filepath: Cert.config[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
+ elsif !Spaceship::ConnectAPI.token.nil?
+ UI.message("Using existing authorization token for App Store Connect API")
else
+ # Username is now optional since addition of App Store Connect API Key
+ # Force asking for username to prompt user if not already set
+ Cert.config.fetch(:username, force_ask: true)
+
UI.message("Starting login with user '#{Cert.config[:username]}'")
Spaceship::ConnectAPI.login(Cert.config[:username], nil, use_portal: true, use_tunes: false)
UI.message("Successfully logged in")
end
end
- def api_token
- @api_token ||= Spaceship::ConnectAPI::Token.create(Cert.config[:api_key]) if Cert.config[:api_key]
- @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Cert.config[:api_key_path]) if Cert.config[:api_key_path]
- return @api_token
- end
-
def run
FileUtils.mkdir_p(Cert.config[:output_path])
FastlaneCore::PrintTable.print_values(config: Cert.config, hide_keys: [:output_path], title: "Summary for cert #{Fastlane::VERSION}")
@@ -188,10 +188,10 @@
# Use the signing request to create a new (development|distribution) certificate
begin
certificate = Spaceship::ConnectAPI::Certificate.create(
certificate_type: certificate_type,
- csr_content: csr
+ csr_content: csr.to_pem
)
rescue => ex
type_name = (Cert.config[:development] ? "Development" : "Distribution")
if ex.to_s.include?("You already have a current")
UI.user_error!("Could not create another #{type_name} certificate, reached the maximum number of available #{type_name} certificates.", show_github_issues: true)