Class: Fastlane::Actions::UploadToSimplemdmAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



32
33
34
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 32

def self.authors
  ["iotashan"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 41

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_key,
                                 env_name: "SIMPLEMDM_API_KEY", # The name of the environment variable
                                 description: "API Token for SimpleMDM"), # a short description of this parameter
    FastlaneCore::ConfigItem.new(key: :app_id,
                                 env_name: "SIMPLEMDM_APP_ID",
                                 description: "The SimpleMDM App ID that will be uploaded",
                                 is_string: false),
    FastlaneCore::ConfigItem.new(key: :ipa_path,
                                 env_name: "SIMPLEMDM_IPA_PATH",
                                 description: "The the path to the IPA",
                                 default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :name,
                                 env_name: "SIMPLEMDM_APP_NAME", # The name of the environment variable
                                 optional: true,
                                 description: "The name that SimpleMDM will use to reference this app. If left blank, SimpleMDM will automatically set this to the app name specified by the binary"), # a short description of this parameter
    FastlaneCore::ConfigItem.new(key: :deploy_to,
                                 env_name: "SIMPLEMDM_DEPLOY_TO", # The name of the environment variable
                                 description: "Deploy the app to associated devices immediately after the app has been uploaded and processed. Possible values are none, outdated or all", # a short description of this parameter
                                 default_value: "none",
                                 verify_block: proc do |value|
                                    accepted_formats = ["none", "outdated", "all"]
                                    UI.user_error!("Only \"none\" \"outdated\" or \"all\" values are allowed, you provided \"#{value}\"") unless accepted_formats.include? value
                                  end)
  ]
end

.descriptionObject



28
29
30
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 28

def self.description
  "Upload IPA to Simple MDM"
end

.detailsObject



36
37
38
39
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 36

def self.details
  # Optional:
  "When using SimpleMDM for iOS app distribution, this provides an automate way to send updates directly to SimpleMDM"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 72

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/simplemdm/actions/upload_to_simplemdm_action.rb', line 11

def self.run(params)
  SimpleMDM.api_key = (params[:api_key]).to_s

  data = File.open((params[:ipa_path]).to_s)

  app = SimpleMDM::App.find(params[:app_id])

  app.binary = data
  app.name = params[:name] if params[:name]

  UI.message("Uploading #{app.name} `#{params[:ipa_path]}` to SimpleMDM for app ID #{params[:app_id]} deploying to #{params[:deploy_to]}")

  app.save(params[:deploy_to])

  UI.message("Uploaded #{app.name} (#{app.bundle_identifier} #{app.version})")
end