Class: Fastlane::Actions::LatestHockeyappVersionNumberAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



60
61
62
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 60

def self.authors
  ["Travis Palmer"]
end

.available_optionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 29

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :app_name,
                                 env_name: "FL_LATEST_HOCKEYAPP_VERSION_NUMBER_APP_NAME",
                                 description: "The app name to use when fetching the version number",
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("No App Name for LatestHockeyappVersionNumberAction given, pass using `app_name: 'name'`") unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: "FL_HOCKEY_API_TOKEN",
                                 description: "API Token for Hockey Access",
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("No API token for LatestHockeyappVersionNumberAction given, pass using `api_token: 'token'`") unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :release_type,
                                 env_name: "FL_LATEST_HOCKEYAPP_VERSION_NUMBER_RELEASE_TYPE",
                                 description: "The release type to use when fetching the version number: Beta=0, Store=1, Alpha=2, Enterprise=3",
                                 default_value: "0"),
    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: "FL_LATEST_HOCKEYAPP_VERSION_NUMBER_PLATFORM",
                                 description: "The platform to use when fetching the version number: iOS, Android, Mac OS, Windows Phone, Custom",
                                 default_value: "iOS")
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 21

def self.description
  "Easily fetch the most recent HockeyApp version number for your app"
end

.detailsObject



25
26
27
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 25

def self.details
  "Provides a way to have increment_build_number be based on the latest HockeyApp version"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 64

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

.return_valueObject



56
57
58
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 56

def self.return_value
  "The most recent version number for the specified app"
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/latest_hockeyapp_version_number/actions/latest_hockeyapp_version_number_action.rb', line 4

def self.run(params)
  require 'hockeyapp'

  HockeyApp::Config.configure do |config|
    config.token = params[:api_token]
  end

  UI.message "Fetching latest version of #{params[:app_name]} from HockeyApp"
  client = HockeyApp.build_client
  apps = client.get_apps
  app = apps.find { |a| a.title == params[:app_name] && a.platform == params[:platform] && a.release_type == params[:release_type].to_i }
  version = app.versions.first.version.to_i
  UI.message "Found version #{version}"

  version
end