Class: Fastlane::Actions::DeploygateAction

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

Constant Summary collapse

DEPLOYGATE_URL_BASE =
'https://deploygate.com'

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, method_missing, other_action, return_value, sh, step_text

Class Method Details

.authorObject



133
134
135
# File 'lib/fastlane/actions/deploygate.rb', line 133

def self.author
  "tnj"
end

.available_optionsObject



89
90
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
122
123
# File 'lib/fastlane/actions/deploygate.rb', line 89

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: "DEPLOYGATE_API_TOKEN",
                                 description: "Deploygate API Token",
                                 verify_block: proc do |value|
                                   UI.user_error!("No API Token for DeployGate given, pass using `api_token: 'token'`") unless value.to_s.length > 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :user,
                                 env_name: "DEPLOYGATE_USER",
                                 description: "Target username or organization name",
                                 verify_block: proc do |value|
                                   UI.user_error!("No User for app given, pass using `user: 'user'`") unless value.to_s.length > 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :ipa,
                                 env_name: "DEPLOYGATE_IPA_PATH",
                                 description: "Path to your IPA file. Optional if you use the `gym` or `xcodebuild` action",
                                 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: :message,
                                 env_name: "DEPLOYGATE_MESSAGE",
                                 description: "Release Notes",
                                 default_value: "No changelog provided"),
    FastlaneCore::ConfigItem.new(key: :distribution_key,
                                 optional: true,
                                 env_name: "DEPLOYGATE_DISTRIBUTION_KEY",
                                 description: "Target Distribution Key"),
    FastlaneCore::ConfigItem.new(key: :release_note,
                                 optional: true,
                                 env_name: "DEPLOYGATE_RELEASE_NOTE",
                                 description: "Release note for distribution page")
  ]
end

.descriptionObject



85
86
87
# File 'lib/fastlane/actions/deploygate.rb', line 85

def self.description
  "Upload a new build to DeployGate"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/fastlane/actions/deploygate.rb', line 16

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

.outputObject



125
126
127
128
129
130
131
# File 'lib/fastlane/actions/deploygate.rb', line 125

def self.output
  [
    ['DEPLOYGATE_URL', 'URL of the newly uploaded build'],
    ['DEPLOYGATE_REVISION', 'auto incremented revision number'],
    ['DEPLOYGATE_APP_INFO', 'Contains app revision, bundle identifier, etc.']
  ]
end

.run(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fastlane/actions/deploygate.rb', line 20

def self.run(options)
  require 'shenzhen'
  require 'shenzhen/plugins/deploygate'

  # Available options: https://deploygate.com/docs/api
  UI.success('Starting with ipa upload to DeployGate... this could take some time ⏳')

  client = Shenzhen::Plugins::DeployGate::Client.new(
    options[:api_token],
    options[:user]
  )

  return options[:ipa] if Helper.test?

  filter = [:message, :distribution_key, :release_note]
  response = client.upload_build(
    options[:ipa],
    options.values.select do |key, _|
      filter.include? key
    end)
  if parse_response(response)
    UI.message("DeployGate URL: #{Actions.lane_context[SharedValues::DEPLOYGATE_URL]}")
    UI.success("Build successfully uploaded to DeployGate as revision \##{Actions.lane_context[SharedValues::DEPLOYGATE_REVISION]}!")
  else
    UI.user_error!("Error when trying to upload ipa to DeployGate")
  end
end