Class: Fastlane::Actions::UploadGithubReleaseAssetsAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



33
34
35
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 33

def self.authors
  ['Automattic']
end

.available_optionsObject



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
75
76
77
78
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :repository,
                                 description: 'The slug (`<org>/<repo>`) of the GitHub repository containing the release',
                                 optional: false,
                                 type: String,
                                 verify_block: proc do |value|
                                   UI.user_error!('Repository cannot be empty') if value.to_s.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :version,
                                 description: 'The version of the release. Used as the git tag name',
                                 optional: false,
                                 type: String,
                                 verify_block: proc do |value|
                                   UI.user_error!('Version cannot be empty') if value.to_s.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :release_assets,
                                 description: 'Assets to upload',
                                 type: Array,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!('You must provide at least one release asset') if value.nil? || value.empty?
                                   value.each do |asset|
                                     UI.user_error!('release_assets must contain file paths') unless asset.is_a?(String) && !asset.empty?
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :replace_existing,
                                 description: 'True to delete existing release assets with matching filenames before uploading. False to fail if a matching asset exists',
                                 optional: true,
                                 default_value: true,
                                 type: Boolean),
    Fastlane::Helper::GithubHelper.github_token_config_item,
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 29

def self.description
  'Uploads assets to an existing GitHub Release'
end

.detailsObject



41
42
43
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 41

def self.details
  'Uploads assets to an existing GitHub Release. By default, existing release assets with matching filenames are replaced; when replace_existing is false, matching assets cause the action to fail.'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 80

def self.is_supported?(platform)
  true
end

.return_valueObject



37
38
39
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 37

def self.return_value
  'The URL of the GitHub Release'
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_github_release_assets_action.rb', line 9

def self.run(params)
  repository = params[:repository]
  version = params[:version]
  assets = params[:release_assets]
  replace_existing = params[:replace_existing]

  UI.message("Uploading #{assets.count} GitHub Release asset(s) to #{repository} #{version}.")

  github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
  url = github_helper.upload_release_assets(
    repository: repository,
    version: version,
    assets: assets,
    replace_existing: replace_existing
  )

  UI.success("Successfully uploaded GitHub Release assets. You can see the release at '#{url}'")
  url
end