Class: Fastlane::Actions::CreateGithubReleaseAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::CreateGithubReleaseAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
45 46 47 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 45 def self. ['Automattic'] end |
.available_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 58 def self. [ FastlaneCore::ConfigItem.new(key: :repository, env_name: 'GHHELPER_REPOSITORY', description: 'The slug (`<org>/<repo>`) of the GitHub repository we want to create the release on', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :version, env_name: 'GHHELPER_CREATE_RELEASE_VERSION', description: 'The version of the release', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :target, env_name: 'GHHELPER_TARGET_COMMITISH', description: 'The branch name or commit SHA the new tag should point to - if that tag does not exist yet when publishing the release. If omitted, will default to the current HEAD commit at the time of this call', optional: true, type: String), FastlaneCore::ConfigItem.new(key: :release_notes_file_path, env_name: 'GHHELPER_CREATE_RELEASE_NOTES', description: 'The path to the file that contains the release notes', optional: true, type: String), FastlaneCore::ConfigItem.new(key: :release_assets, env_name: 'GHHELPER_CREATE_RELEASE_ASSETS', description: 'Assets to upload', type: Array, optional: false), FastlaneCore::ConfigItem.new(key: :prerelease, env_name: 'GHHELPER_CREATE_RELEASE_PRERELEASE', description: 'True if this is a pre-release', optional: true, default_value: false, type: Boolean), FastlaneCore::ConfigItem.new(key: :is_draft, env_name: 'GHHELPER_CREATE_RELEASE_IS_DRAFT', description: 'True to create the GitHub release as a draft (instead of publishing it immediately)', optional: true, default_value: true, type: Boolean), Fastlane::Helper::GithubHelper.github_token_config_item, ] end |
.description ⇒ Object
41 42 43 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 41 def self.description 'Creates a release and uploads the provided assets' end |
.details ⇒ Object
53 54 55 56 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 53 def self.details # Optional: 'Creates a release and uploads the provided assets' end |
.is_supported?(platform) ⇒ Boolean
101 102 103 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 101 def self.is_supported?(platform) true end |
.return_value ⇒ Object
49 50 51 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 49 def self.return_value 'The URL of the created 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 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb', line 9 def self.run(params) repository = params[:repository] version = params[:version] assets = params[:release_assets] release_notes = params[:release_notes_file_path].nil? ? '' : File.read(params[:release_notes_file_path]) # Replace full URLs to PRs/Issues that are in `[https://some-url]` brackets with shorthand, because GitHub does not render them properly otherwise. # That syntax is sometimes used by devs in `RELEASE-NOTES.txt` when pointing to a PR to another repo (e.g. Gutenberg PR from WP repo). # We should NOT transform URLs to PRs/Issues that are in `[text](url)` form (those are valid), only the ones directly in `[]` brackets. release_notes.gsub!(%r{\[https://github.com/([^/]*/[^/]*)/(pulls?|issues?)/([0-9]*)\]}, '[\1#\3]') prerelease = params[:prerelease] is_draft = params[:is_draft] UI.("Creating #{is_draft ? 'draft ' : ''}release #{version} in #{repository}.") # Verify assets assets.each do |file_path| UI.user_error!("Can't find file #{file_path}!") unless File.exist?(file_path) end github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token]) url = github_helper.create_release( repository: repository, version: version, target: params[:target], description: release_notes, assets: assets, prerelease: prerelease, is_draft: is_draft ) UI.success("Successfully created GitHub Release. You can see it at '#{url}'") url end |