Class: Fastlane::Actions::ReleaseNotesFromCommitsAction

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

Class Method Summary collapse

Class Method Details

.authorObject



45
46
47
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 45

def self.author
  "Piotrek Dubiel"
end

.available_optionsObject



29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 29

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :current_version,
                                 env_name: "",
                                 description: "Git ref of current version",
                                 optional: true,
                                 default_value: 'HEAD')
  ]
end

.descriptionObject



25
26
27
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 25

def self.description
  "Extracts release notes from git commit messages since last tag"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 49

def self.is_supported?(platform)
  true
end

.outputObject



39
40
41
42
43
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 39

def self.output
  [
    ['RELEASE_NOTES', 'Release notes extracted from git commits']
  ]
end

.run(config) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/polidea/actions/release_notes_from_commits.rb', line 8

def self.run(config)
  Fastlane::Polidea.session.action_launched("release_notes_from_commits", config)

  current_version = config[:current_version]
  previous_version = sh("git describe --abbrev=0 --tags #{current_version}^").strip
  messages = sh("git log --oneline --pretty=format:'%s' #{previous_version}..#{current_version} | grep -Ev '^Merge'").strip
  release_notes = messages.split("\n").map { |note| "- #{note}" }.join("\n")

  UI.success "Extracted release notes:\n#{release_notes}"
  Actions.lane_context[SharedValues::RELEASE_NOTES] = release_notes
  ENV[SharedValues::RELEASE_NOTES.to_s] = release_notes

  Fastlane::Polidea.session.action_completed("release_notes_from_commits")

  release_notes
end