Class: Fastlane::Actions::GenerateReleaseNotesAction

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

Overview

Generate release notes based on git changelog

Class Method Summary collapse

Class Method Details

.authorsObject



54
55
56
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 54

def self.authors
  ["samdc@apadmi.com"]
end

.available_optionsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 62

def self.available_options
  Apadmi::Grout::CommonOptions.board_options + [
    FastlaneCore::ConfigItem.new(key: :tickets_moved_by_build,
                                 description: "Any tickets who's state was moved by this build",
                                 default_value: [],
                                 type: Array,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :release_notes_title,
                                 description: "The title of the release notes",
                                 env_name: "RELEASE_NOTES_TITLE",
                                 type: String,
                                 verify_block: proc do |value|
                                   UI.user_error!("Didn't pass a valid project title") unless value
                                 end,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :oldest_ref,
                                 description: "Changelog between 2 git refs, this is the furthest back of those",
                                 type: String,
                                 verify_block: proc do |value|
                                   UI.user_error!("Didn't pass a valid ref") unless value
                                 end,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :latest_ref,
                                 description: "Changelog between 2 git refs, this is the most recent of those",
                                 default_value: "HEAD",
                                 type: String,
                                 verify_block: proc do |value|
                                   UI.user_error!("Didn't pass a valid ref") unless value
                                 end),
    FastlaneCore::ConfigItem.new(key: :commit_hash,
                                 description: "Commit hash of commit being built",
                                 env_name: "GIT_CLONE_COMMIT_HASH",
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :date_string,
                                 description: "Commit hash of commit being built",
                                 default_value: Time.now.strftime("%d/%m/%Y"),
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ci_build_number,
                                 description: "Build number provided by CI",
                                 env_name: "BITRISE_BUILD_NUMBER", # Probably want to make this not bitrise specific, but this is convenient
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ci_build_url,
                                 description: "Build URL of CI job",
                                 env_name: "BITRISE_BUILD_URL", # Probably want to make this not bitrise specific, but this is convenient
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :app_version,
                                 description: "Current App Version",
                                 type: String,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("Didn't pass a valid app version") unless value
                                 end),
    FastlaneCore::ConfigItem.new(key: :min_sdk_int,
                                 description: "Minimum OS version supported by the app",
                                 type: String,
                                 optional: true,
                                 default_value: ""),
    FastlaneCore::ConfigItem.new(key: :templates,
                                 description: "Release notes templates",
                                 default_value: Apadmi::Grout::Templates.default,
                                 type: Apadmi::Grout::Templates),
    FastlaneCore::ConfigItem.new(key: :output_dir,
                                 description: "Directory in which to save the release notes file",
                                 default_value: ENV["BITRISE_DEPLOY_DIR"] || "#{Apadmi::Grout::GitUtils.git_root}/build",
                                 type: String)
  ]
end

.descriptionObject



50
51
52
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 50

def self.description
  "Generate release notes based on git changelog"
end

.is_supported?(_platform) ⇒ Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 134

def self.is_supported?(_platform)
  true
end

.return_valueObject



58
59
60
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 58

def self.return_value
  "Array of two items: [release_notes_as_string, path_to_file_on_disk]"
end

.run(params) ⇒ Object



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
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/apadmi_grout/actions/generate_release_notes_action.rb', line 12

def self.run(params)
  logger = FastLane::FastlaneLogger.new
  logger.message("Generating Release Notes")

  build_tools = Apadmi::Grout::DIWrapper.di(params, logger)

  logger.message("Finding changelog between #{params[:oldest_ref]} and #{params[:latest_ref]}")
  changelog = Fastlane::Actions::ChangelogFromGitCommitsAction.run(
    pretty: "- %s",
    between: [params[:oldest_ref], params[:latest_ref]],
    quiet: false,
    merge_commit_filtering: "only_include_merges"
  )

  config = Apadmi::Grout::ReleaseNotesConfig.new(
    params[:release_notes_title],
    params[:app_version],
    params[:min_sdk_int],
    params[:date_string],
    params[:tickets_moved_by_build],
    build_tools.issues_from_changelog_action.run(changelog),
    params[:commit_hash],
    params[:ci_build_number],
    params[:ci_build_url],
    params[:templates]
  )

  logger.message("Generating Release Notes")
  release_notes = build_tools.generate_release_notes_action.run(config)

  FileUtils.mkdir_p(params[:output_dir])
  file_name = "#{params[:output_dir]}/#{params[:release_notes_title]}-#{params[:app_version]}.md"

  File.write(file_name, release_notes)
  logger.success("Saved Release Notes to #{file_name}")
  [release_notes, file_name]
end