Class: Fastlane::Actions::TouchChangelogAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::TouchChangelogAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb
Documentation collapse
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
Class Method Summary collapse
Class Method Details
.available_options ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb', line 51 def self. [ FastlaneCore::ConfigItem.new( key: :github_repo, env_name: 'GITHUB_REPOSITORY', description: 'The owner and repository name. For example, octocat/Hello-World' ), FastlaneCore::ConfigItem.new( key: :changelog_path, description: 'The path to your project CHANGELOG.md', default_value: './CHANGELOG.md' ), FastlaneCore::ConfigItem.new( key: :release_version, description: 'The release version, according to semantic versioning' ) ] end |
.description ⇒ Object
43 44 45 |
# File 'lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb', line 43 def self.description 'Updates CHANGELOG.md file with release' end |
.details ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb', line 47 def self.details 'Use this action to rename your unrelease section to your release version and add a new unreleased section to your project CHANGELOG.md' end |
.is_supported?(platform) ⇒ Boolean
70 71 72 |
# File 'lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb', line 70 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
4 5 6 7 8 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 |
# File 'lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb', line 4 def self.run(params) UI.("Starting to update '#{params[:changelog_path]}'") file_data = File.readlines(params[:changelog_path]) upcoming_line = -1 changes_since_last_release = '' File.open(params[:changelog_path]).each.with_index do |line, index| if upcoming_line != -1 break if line.start_with?('# [') changes_since_last_release += line elsif line == "# Upcoming\n" upcoming_line = index end end file_data[upcoming_line] = "# [#{params[:release_version]}](https://github.com/#{params[:github_repo]}/releases/tag/#{params[:release_version]})" today = Time.now.strftime('%B %d, %Y') file_data.insert(upcoming_line + 1, "_#{today}_") file_data.insert(upcoming_line, '# Upcoming') file_data.insert(upcoming_line + 1, '') file_data.insert(upcoming_line + 2, '### 🔄 Changed') file_data.insert(upcoming_line + 3, '') changelog = File.open(params[:changelog_path], 'w') changelog.puts(file_data) changelog.close UI.success("Successfully updated #{params[:changelog_path]}") changes_since_last_release end |