Class: Fastlane::Actions::AppStoreConnectApiKeyAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



79
80
81
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 79

def self.author
  ["joshdholtz"]
end

.available_optionsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :key_id,
                                 env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID",
                                 description: "The key ID"),
    FastlaneCore::ConfigItem.new(key: :issuer_id,
                                 env_name: "APP_STORE_CONNECT_API_KEY_ISSUER_ID",
                                 description: "The issuer ID"),
    FastlaneCore::ConfigItem.new(key: :key_filepath,
                                 env_name: "APP_STORE_CONNECT_API_KEY_KEY_FILEPATH",
                                 description: "The path to the key p8 file",
                                 optional: true,
                                 conflicting_options: [:key_content],
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find key p8 file at path '#{value}'") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :key_content,
                                 env_name: "APP_STORE_CONNECT_API_KEY_KEY",
                                 description: "The content of the key p8 file",
                                 optional: true,
                                 conflicting_options: [:filepath]),
    FastlaneCore::ConfigItem.new(key: :duration,
                                 env_name: "APP_STORE_CONNECT_API_KEY_DURATION",
                                 description: "The token session duration",
                                 optional: true,
                                 type: Integer),
    FastlaneCore::ConfigItem.new(key: :in_house,
                                 env_name: "APP_STORE_CONNECT_API_KEY_IN_HOUSE",
                                 description: "Is App Store or Enterprise (in house) team? App Store Connect API cannot not determine this on its own (yet)",
                                 optional: true,
                                 type: Boolean)
  ]
end

.categoryObject



115
116
117
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 115

def self.category
  :app_store_connect
end

.descriptionObject



35
36
37
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 35

def self.description
  "Load the App Store Connect API token to use in other fastlane tools and actions"
end

.detailsObject



87
88
89
90
91
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 87

def self.details
  [
    "Load the App Store Connect API token to use in other fastlane tools and actions"
  ].join("\n")
end

.example_codeObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 93

def self.example_code
  [
    'app_store_connect_api_key(
      key_id: "D83848D23",
      issuer_id: "227b0bbf-ada8-458c-9d62-3d8022b7d07f",
      key_filepath: "D83848D23.p8"
    )',
    'app_store_connect_api_key(
      key_id: "D83848D23",
      issuer_id: "227b0bbf-ada8-458c-9d62-3d8022b7d07f",
      key_filepath: "D83848D23.p8",
      duration: 200,
      in_house: true
    )',
    'app_store_connect_api_key(
      key_id: "D83848D23",
      issuer_id: "227b0bbf-ada8-458c-9d62-3d8022b7d07f",
      key_content: "-----BEGIN EC PRIVATE KEY-----\nfewfawefawfe\n-----END EC PRIVATE KEY-----"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



83
84
85
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 83

def self.is_supported?(platform)
  true
end

.outputObject



73
74
75
76
77
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 73

def self.output
  [
    ['APP_STORE_CONNECT_API_KEY', 'The App Store Connect API key information used for authorization requests. This hash can be passed directly into the :api_key options on other tools or into Spaceship::ConnectAPI::Token.create method']
  ]
end

.run(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'fastlane/lib/fastlane/actions/app_store_connect_api_key.rb', line 8

def self.run(options)
  key_id = options[:key_id]
  issuer_id = options[:issuer_id]
  key_content = options[:key_content]
  key_filepath = options[:key_filepath]
  duration = options[:duration]
  in_house = options[:in_house]

  if key_content.nil? && key_filepath.nil?
    UI.user_error!(":key_content or :key_filepath is required")
  end

  # This hash matches the named arguments on
  # the Spaceship::ConnectAPI::Token.create method
  key = {
    key_id: key_id,
    issuer_id: issuer_id,
    key: key_content || File.binread(key_filepath),
    duration: duration,
    in_house: in_house
  }

  Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY] = key

  return key
end