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'

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, lane_context, method_missing, other_action, return_value, sample_return_value, sh, step_text

Class Method Details

.authorObject



157
158
159
# File 'lib/fastlane/actions/deploygate.rb', line 157

def self.author
  "tnj"
end

.available_optionsObject



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
124
125
126
127
128
129
130
131
# File 'lib/fastlane/actions/deploygate.rb', line 97

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

.categoryObject



153
154
155
# File 'lib/fastlane/actions/deploygate.rb', line 153

def self.category
  :beta
end

.descriptionObject



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

def self.description
  "Upload a new build to [DeployGate](https://deploygate.com/)"
end

.detailsObject



90
91
92
93
94
95
# File 'lib/fastlane/actions/deploygate.rb', line 90

def self.details
  [
    "You can retrieve your username and API token on [your settings page](https://deploygate.com/settings)",
    "More information about the available options can be found in the [DeployGate Push API document](https://deploygate.com/docs/api)."
  ].join("\n")
end

.example_codeObject



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/fastlane/actions/deploygate.rb', line 141

def self.example_code
  [
    'deploygate(
      api_token: "...",
      user: "target username or organization name",
      ipa: "./ipa_file.ipa",
      message: "Build #{lane_context[SharedValues::BUILD_NUMBER]}",
      distribution_key: "(Optional) Target Distribution Key"
    )'
  ]
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



133
134
135
136
137
138
139
# File 'lib/fastlane/actions/deploygate.rb', line 133

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
47
# 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