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



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

def self.authors
  ['Automattic']
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
71
72
73
74
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb', line 41

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



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

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

.detailsObject



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

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)


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

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

.outputObject



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

def self.output
end

.return_valueObject



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

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



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

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