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
- .check_and_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
51 52 53 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 51 def self. ['Automattic'] end |
.available_options ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 64 def self. [ FastlaneCore::ConfigItem.new(key: :version, env_name: 'GHHELPER_EXTRACT_NOTES_VERSION', description: 'The version of the release', optional: false, is_string: true), 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, is_string: true), 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, is_string: true), ] end |
.check_and_commit_extracted_notes_file(file_path, version) ⇒ Object
42 43 44 45 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 42 def self.check_and_commit_extracted_notes_file(file_path, version) Action.sh("git add #{file_path}") Action.sh("git diff-index --quiet HEAD || git commit -m \"Update draft release notes for #{version}.\"") end |
.description ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 47 def self.description 'Extract the release notes for a specific version' end |
.details ⇒ Object
59 60 61 62 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 59 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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 23 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
84 85 86 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 84 def self.is_supported?(platform) true end |
.return_value ⇒ Object
55 56 57 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb', line 55 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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_file = File.open(extracted_notes_file_path, 'w') unless extracted_notes_file_path.blank? extract_notes(release_notes_file_path, version) do |line| extracted_notes_file.nil? ? puts(line) : extracted_notes_file.write(line) end unless extracted_notes_file.nil? extracted_notes_file.close() check_and_commit_extracted_notes_file(extracted_notes_file_path, version) end end |