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



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

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



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

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

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

def self.run(params)
  UI.message("Getting changelog for #{params[:version]}")

  changes = ''
  start_token = '# '
  version_found = false
  File.readlines(params[:changelog_path]).each do |line|
    unless version_found
      version_found = line.start_with?("#{start_token}#{params[:version]}") || line.start_with?("#{start_token}[#{params[:version]}")
      next
    end

    break if line.start_with?(start_token)

    changes << line
  end

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