Class: Fastlane::Actions::ImportCertificateAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/import_certificate.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



39
40
41
# File 'lib/fastlane/actions/import_certificate.rb', line 39

def self.authors
  ["gin0606"]
end

.available_optionsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/actions/import_certificate.rb', line 19

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :keychain_name,
                                 env_name: "KEYCHAIN_NAME",
                                 description: "Keychain the items should be imported to",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :certificate_path,
                                 description: "Path to certificate",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :certificate_password,
                                 description: "Certificate password",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :log_output,
                                 description: "If output should be logged to the console",
                                 type: TrueClass,
                                 default_value: false,
                                 optional: true)
  ]
end

.categoryObject



61
62
63
# File 'lib/fastlane/actions/import_certificate.rb', line 61

def self.category
  :code_signing
end

.descriptionObject



15
16
17
# File 'lib/fastlane/actions/import_certificate.rb', line 15

def self.description
  "Import certificate from inputfile into a keychain"
end

.detailsObject



47
48
49
# File 'lib/fastlane/actions/import_certificate.rb', line 47

def self.details
  "Import certificates into the current default keychain. Use `create_keychain` to create a new keychain."
end

.example_codeObject



51
52
53
54
55
56
57
58
59
# File 'lib/fastlane/actions/import_certificate.rb', line 51

def self.example_code
  [
    'import_certificate(certificate_path: "certs/AppleWWDRCA.cer")',
    'import_certificate(
      certificate_path: "certs/dist.p12",
      certificate_password: ENV["CERTIFICATE_PASSWORD"] || "default"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/fastlane/actions/import_certificate.rb', line 43

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fastlane/actions/import_certificate.rb', line 6

def self.run(params)
  command = "security import #{params[:certificate_path].shellescape} -k ~/Library/Keychains/#{params[:keychain_name].shellescape}"
  command << " -P #{params[:certificate_password].shellescape}" if params[:certificate_password]
  command << " -T /usr/bin/codesign"
  command << " -T /usr/bin/security"

  Fastlane::Actions.sh(command, log: params[:log_output])
end