Class: Fastlane::Actions::AndroidDownloadFileByVersionAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



81
82
83
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 81

def self.authors
  ['Automattic']
end

.available_optionsObject



39
40
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
71
72
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :library_name,
                                 description: 'The display name of the library',
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :import_key,
                                 description: 'The key which is used in build.gradle to reference the version of the library to import',
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :repository,
                                 description: "The GitHub repository slug ('<orgname>/<reponame>') which hosts the library project",
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :file_path,
                                 description: 'The path of the file to download',
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :download_folder,
                                 description: 'The download folder',
                                 type: String,
                                 optional: true,
                                 default_value: Dir.tmpdir),
    FastlaneCore::ConfigItem.new(key: :github_release_prefix,
                                 description: 'The prefix which is used in the GitHub release title',
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :build_gradle_path,
                                 description: 'Path to the build.gradle file',
                                 type: String,
                                 optional: true),
    Fastlane::Helper::GithubHelper.github_token_config_item,
  ]
end

.descriptionObject



30
31
32
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 30

def self.description
  'Downloads a file from a GitHub release based on the version used by the client app'
end

.detailsObject



34
35
36
37
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 34

def self.details
  'This action extracts the version of the library which is imported by the client app' \
    'and downloads the request file from the relevant GitHub release'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 85

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

.outputObject



74
75
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 74

def self.output
end

.return_valueObject



77
78
79
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 77

def self.return_value
  'The path where the file was downloaded to (typically <download_folder>/<basename(file_path)>), or nil if there was an issue downloading the file'
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 4

def self.run(params)
  require_relative '../../helper/android/android_localize_helper'
  require_relative '../../helper/github_helper'

  build_gradle_path = params[:build_gradle_path]

  version = Fastlane::Helper::Android::VersionHelper.get_library_version_from_gradle_config(
    build_gradle_path: build_gradle_path,
    import_key: params[:import_key]
  )
  UI.user_error!("Can't find any reference for key #{params[:import_key]}") if version.nil?
  UI.message "Downloading #{params[:file_path]} from #{params[:repository]} at version #{version} to #{params[:download_folder]}"

  github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
  github_helper.download_file_from_tag(
    repository: params[:repository],
    tag: "#{params[:github_release_prefix]}#{version}",
    file_path: params[:file_path],
    download_folder: params[:download_folder]
  )
end