Class: Fastlane::Actions::MatchImportMultipleAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



80
81
82
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 80

def self.authors
  ["Bogdan Matran"]
end

.available_optionsObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 91

def self.available_options
  require 'match/options'

  plugin_options = [
    FastlaneCore::ConfigItem.new(
      key: :profile_paths,
      description: "Array (or comma-separated string) of provisioning profile paths to import. Prompts interactively if omitted, mirroring `fastlane match import`",
      skip_type_validation: true,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :cert_path,
      description: "Path to the .cer certificate (shared across all profiles). Prompts interactively if omitted",
      type: String,
      optional: true,
      verify_block: proc { |value| UI.user_error!("Certificate not found at path: #{value}") if value && !File.exist?(value) }
    ),
    FastlaneCore::ConfigItem.new(
      key: :p12_path,
      description: "Path to the .p12 private key (shared across all profiles). Prompts interactively if omitted",
      type: String,
      optional: true,
      verify_block: proc { |value| UI.user_error!("Private key not found at path: #{value}") if value && !File.exist?(value) }
    )
  ]

  reserved_keys = plugin_options.map(&:key)
  match_options = ::Match::Options.available_options.reject { |opt| reserved_keys.include?(opt.key) }

  plugin_options + match_options
end

.categoryObject



139
140
141
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 139

def self.category
  :code_signing
end

.descriptionObject



65
66
67
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 65

def self.description
  "Import multiple provisioning profiles into a match repo in a single invocation"
end

.detailsObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 69

def self.details
  <<~DETAILS
    Wraps fastlane match's Importer so you can pass an array of provisioning
    profile paths together with a single shared certificate and private key.
    Iterates over the profiles and delegates to the unmodified upstream
    Match::Importer#import_cert. All match options (storage backend, type,
    team, App Store Connect API key, encryption settings, Matchfile, etc.)
    are forwarded as-is.
  DETAILS
end

.example_codeObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 123

def self.example_code
  [
    'match_import_multiple(
      type: "appstore",
      git_url: "git@github.com:your-org/certs.git",
      cert_path: "./assets/dist.cer",
      p12_path: "./assets/dist.p12",
      profile_paths: [
        "./assets/AppStore_app1.mobileprovision",
        "./assets/AppStore_app2.mobileprovision",
        "./assets/AppStore_app3.mobileprovision"
      ]
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 87

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.resolve_profile_paths(value) ⇒ Object

Mirrors upstream match’s interactive UX:

- Array given           -> use as-is
- String (single/CSV)   -> split on commas
- nil                   -> prompt the user (comma-separated input)

Each path is normalized to an absolute path and verified to exist.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 46

def self.resolve_profile_paths(value)
  raw = case value
        when Array
          value
        when String
          value.split(",")
        when nil
          UI.input("Provisioning profile (.mobileprovision or .provisionprofile) path(s), comma-separated, or leave empty to skip:").split(",")
        else
          UI.user_error!("Invalid profile_paths value: #{value.inspect}")
        end

  raw.map { |entry| entry.to_s.strip }.reject(&:empty?).map do |path|
    absolute = File.absolute_path(path)
    UI.user_error!("Provisioning profile does not exist at path: #{absolute}") unless File.exist?(absolute)
    absolute
  end
end

.return_valueObject



84
85
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 84

def self.return_value
end

.run(params) ⇒ 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
34
35
36
37
38
39
# File 'lib/fastlane/plugin/match_import_multiple/actions/match_import_multiple_action.rb', line 8

def self.run(params)
  require 'match/importer'

  # Mirror what `fastlane match import` does after building its Configuration:
  # load Matchfile defaults so storage/type/etc are picked up automatically.
  begin
    params.load_configuration_file("Matchfile")
  rescue StandardError
    # Matchfile is optional
  end

  importer = ::Match::Importer.new

  # Same prompt order as upstream `fastlane match import`: cert -> p12 -> profile(s).
  cert_path = importer.ensure_valid_file_path(params[:cert_path], "Certificate", ".cer")
  p12_path  = importer.ensure_valid_file_path(params[:p12_path], "Private key", ".p12")

  profile_paths = resolve_profile_paths(params[:profile_paths])
  UI.user_error!("No provisioning profiles provided") if profile_paths.empty?

  profile_paths.each_with_index do |profile_path, idx|
    UI.message("Importing profile #{idx + 1}/#{profile_paths.length}: #{profile_path}")
    importer.import_cert(
      params,
      cert_path: cert_path,
      p12_path: p12_path,
      profile_path: profile_path
    )
  end

  UI.success("Imported #{profile_paths.length} provisioning profile(s) into the match repo")
end