Class: Fastlane::Actions::ReadChangelogAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/stream_actions/actions/read_changelog.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.available_optionsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/stream_actions/actions/read_changelog.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :version,
      description: 'Release version',
      verify_block: proc do |v|
        UI.user_error!("You need to pass the version of the release you want to obtain the changelog from") if v.nil? || v.empty?
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :changelog_path,
      env_name: 'FL_CHANGELOG_PATH',
      description: 'The path to your project CHANGELOG.md',
      is_string: true,
      default_value: './CHANGELOG.md',
      optional: true
    )
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/plugin/stream_actions/actions/read_changelog.rb', line 29

def self.description
  'Gets updates from the CHANGELOG.md'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fastlane/plugin/stream_actions/actions/read_changelog.rb', line 53

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
# File 'lib/fastlane/plugin/stream_actions/actions/read_changelog.rb', line 4

def self.run(params)
  UI.message("Getting changelog for #{params[:version]}")
  reading_changelog = false
  changes = ''
  changelog_lines = File.readlines(params[:changelog_path])
  changelog_lines.each do |line|
    start_token = '# ['
    if reading_changelog
      break if line.start_with?(start_token)

      changes << line
    end

    reading_changelog = true if line.start_with?("#{start_token}#{params[:version]}")
  end

  UI.user_error!("No changelog found for #{params[:version]}") unless changes.length > 0
  UI.success("Changelog for #{params[:version]}: \n#{changes}")
  changes
end