Class: Fastlane::Actions::ExtractReleaseNotesForVersionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ExtractReleaseNotesForVersionAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .commit_extracted_notes_file(file_path, version) ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .extract_notes(release_notes_file_path, version) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
57 58 59 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 57 def self. ['Automattic'] end |
.available_options ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 70 def self. [ FastlaneCore::ConfigItem.new(key: :version, env_name: 'GHHELPER_EXTRACT_NOTES_VERSION', description: 'The version of the release', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :release_notes_file_path, env_name: 'GHHELPER_EXTRACT_NOTES_FILE_PATH', description: 'The path to the file that contains the release notes', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :extracted_notes_file_path, env_name: 'GHHELPER_EXTRACT_NOTES_EXTRACTED_FILE_PATH', description: 'The path to the file that will contain the extracted release notes', optional: true, type: String), ] end |
.commit_extracted_notes_file(file_path, version) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 44 def self.commit_extracted_notes_file(file_path, version) other_action.git_add(path: file_path) other_action.git_commit( path: file_path, message: "Update draft release notes for #{version}", allow_nothing_to_commit: true ) end |
.description ⇒ Object
53 54 55 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 53 def self.description 'Extract the release notes for a specific version' end |
.details ⇒ Object
65 66 67 68 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 65 def self.details # Optional: 'Given a file containing release notes and a version, extracts the notes for that version into a dedicated file.' end |
.extract_notes(release_notes_file_path, version) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 25 def self.extract_notes(release_notes_file_path, version) state = :discarding File.open(release_notes_file_path).each do |line| case state when :discarding state = :evaluating if line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/) && (line.strip == version) when :evaluating state = line.match(/-/) ? :extracting : :discarding when :extracting if line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/) state = :discarding return else yield(line) end end end end |
.is_supported?(platform) ⇒ Boolean
90 91 92 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 90 def self.is_supported?(platform) true end |
.return_value ⇒ Object
61 62 63 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 61 def self.return_value 'The content of the extracted release notes (the same text as what was written in the `extracted_notes_file_path` if one was provided)' end |
.run(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 6 def self.run(params) version = params[:version] release_notes_file_path = params[:release_notes_file_path] extracted_notes_file_path = params[:extracted_notes_file_path] extracted_notes = '' extract_notes(release_notes_file_path, version) do |line| extracted_notes += line end extracted_notes.chomp!('') # Remove any extra empty line(s) at the end unless extracted_notes_file_path.nil? || extracted_notes_file_path.empty? File.write(extracted_notes_file_path, extracted_notes) commit_extracted_notes_file(extracted_notes_file_path, version) end extracted_notes end |