fastlane-plugin-jira_issues_release_notes 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +254 -16
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_comment_action.rb +200 -0
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/{branch_jira_issues_release_notes_action.rb → jira_feature_validation_action.rb} +16 -47
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_issues_keys_from_commits_action.rb +134 -0
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_changelog_action.rb +182 -0
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb +173 -0
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb +162 -0
- data/lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb +212 -17
- data/lib/fastlane/plugin/jira_issues_release_notes/version.rb +1 -1
- metadata +11 -7
- data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_issues_release_notes_action.rb +0 -289
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-jira_issues_release_notes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Martins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: jira-ruby
|
14
|
+
name: zk-jira-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,8 +159,12 @@ files:
|
|
159
159
|
- LICENSE
|
160
160
|
- README.md
|
161
161
|
- lib/fastlane/plugin/jira_issues_release_notes.rb
|
162
|
-
- lib/fastlane/plugin/jira_issues_release_notes/actions/
|
163
|
-
- lib/fastlane/plugin/jira_issues_release_notes/actions/
|
162
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_comment_action.rb
|
163
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_feature_validation_action.rb
|
164
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_issues_keys_from_commits_action.rb
|
165
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_changelog_action.rb
|
166
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb
|
167
|
+
- lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb
|
164
168
|
- lib/fastlane/plugin/jira_issues_release_notes/helper/jira_issues_release_notes_helper.rb
|
165
169
|
- lib/fastlane/plugin/jira_issues_release_notes/version.rb
|
166
170
|
homepage: https://github.com/erick-martins/fastlane-plugin-jira_issues_release_notes
|
data/lib/fastlane/plugin/jira_issues_release_notes/actions/jira_issues_release_notes_action.rb
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
require 'fastlane/action'
|
2
|
-
require_relative '../helper/jira_issues_release_notes_helper'
|
3
|
-
|
4
|
-
module Fastlane
|
5
|
-
module Actions
|
6
|
-
class JiraIssuesReleaseNotesAction < Action
|
7
|
-
def self.get_last_tag(params)
|
8
|
-
# Try to find the tag
|
9
|
-
command = "git describe --tags --match=#{params[:match]}"
|
10
|
-
Actions.sh(command, log: params[:debug])
|
11
|
-
rescue StandardError
|
12
|
-
UI.message("Tag was not found for match pattern - #{params[:match]}")
|
13
|
-
''
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.get_last_tag_hash(params)
|
17
|
-
command = "git rev-list -n 1 refs/tags/#{params[:tag_name]}"
|
18
|
-
Actions.sh(command, log: params[:debug]).chomp
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.get_commits_from_hash(params)
|
22
|
-
Helper::JiraIssuesReleaseNotesHelper.git_log(
|
23
|
-
pretty: '%s|%b|>',
|
24
|
-
start: params[:hash],
|
25
|
-
debug: params[:debug]
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.run(params)
|
30
|
-
|
31
|
-
@format = params[:format]
|
32
|
-
@format_line_break = @format === 'html' ? '<br />' : "\n"
|
33
|
-
|
34
|
-
tag = get_last_tag(
|
35
|
-
match: params[:tag_prefix],
|
36
|
-
debug: params[:debug]
|
37
|
-
)
|
38
|
-
|
39
|
-
if tag.empty?
|
40
|
-
UI.message("First commit of the branch is taken as a begining of next release")
|
41
|
-
# If there is no tag found we taking the first commit of current branch
|
42
|
-
hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: params[:debug]).chomp
|
43
|
-
else
|
44
|
-
# Tag's format is v2.3.4-5-g7685948
|
45
|
-
# Get a hash of last version tag
|
46
|
-
tag_name = tag.split('-')[0...-2].join('-').strip
|
47
|
-
parsed_version = tag_name.match(params[:tag_version_match])
|
48
|
-
|
49
|
-
if parsed_version.nil?
|
50
|
-
UI.user_error!("Error while parsing version from tag #{tag_name} by using tag_version_match - #{params[:tag_version_match]}. Please check if the tag contains version as you expect and if you are using single brackets for tag_version_match parameter.")
|
51
|
-
end
|
52
|
-
|
53
|
-
version = parsed_version[0]
|
54
|
-
|
55
|
-
# Get a hash of last version tag
|
56
|
-
hash = get_last_tag_hash(
|
57
|
-
tag_name: tag_name,
|
58
|
-
debug: params[:debug]
|
59
|
-
)
|
60
|
-
|
61
|
-
UI.message("Found a tag #{tag_name} associated with version #{version}")
|
62
|
-
end
|
63
|
-
|
64
|
-
# Get commits log between last version and head
|
65
|
-
commits = get_commits_from_hash(
|
66
|
-
hash: hash,
|
67
|
-
debug: params[:debug]
|
68
|
-
)
|
69
|
-
|
70
|
-
regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")
|
71
|
-
|
72
|
-
tickets = tickets(commits: commits, regex: regex)
|
73
|
-
UI.important("Jira tickets: #{tickets}")
|
74
|
-
|
75
|
-
@jira_helper = Helper::JiraIssuesReleaseNotesHelper.jira_helper(
|
76
|
-
host: params[:host],
|
77
|
-
username: params[:username],
|
78
|
-
password: params[:password],
|
79
|
-
context_path: params[:context_path],
|
80
|
-
disable_ssl_verification: params[:disable_ssl_verification]
|
81
|
-
)
|
82
|
-
issues = @jira_helper.get(issues: tickets)
|
83
|
-
|
84
|
-
to_validate = issues.select { |issue| params[:to_validate_status].include?(issue.status.name) }
|
85
|
-
validated = issues.select { |issue| params[:validated_status].include?(issue.status.name) }
|
86
|
-
|
87
|
-
generate_changelog(to_validate: to_validate, validated: validated)
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.generate_changelog(to_validate:, validated:)
|
91
|
-
changelog = []
|
92
|
-
changelog.concat(format_issues(label: 'Tasks to validate', issues: to_validate)) unless to_validate.empty?
|
93
|
-
changelog.concat(['']) unless changelog.to_s.empty?
|
94
|
-
changelog.concat(format_issues(label: 'Validated tasks', issues: validated)) unless validated.empty?
|
95
|
-
# changes = format_issues(issues: issues)
|
96
|
-
changelog = ['No changes included.'] if changelog.to_s.empty?
|
97
|
-
|
98
|
-
changelog.join(@format_line_break)
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.style_text(text:, style:)
|
102
|
-
# formats the text according to the style we're looking to use
|
103
|
-
|
104
|
-
# Skips all styling
|
105
|
-
case style
|
106
|
-
when "title"
|
107
|
-
case @format
|
108
|
-
when "markdown"
|
109
|
-
"# #{text}"
|
110
|
-
when "slack"
|
111
|
-
"*#{text}*"
|
112
|
-
when "html"
|
113
|
-
"<h1>#{text}</h1>"
|
114
|
-
else
|
115
|
-
text
|
116
|
-
end
|
117
|
-
when "heading"
|
118
|
-
case @format
|
119
|
-
when "markdown"
|
120
|
-
"### #{text}"
|
121
|
-
when "slack"
|
122
|
-
"*#{text}*"
|
123
|
-
when "html"
|
124
|
-
"<h3>#{text}</h3>"
|
125
|
-
else
|
126
|
-
"#{text}:"
|
127
|
-
end
|
128
|
-
when "bold"
|
129
|
-
case @format
|
130
|
-
when "markdown"
|
131
|
-
"**#{text}**"
|
132
|
-
when "slack"
|
133
|
-
"*#{text}*"
|
134
|
-
when "html"
|
135
|
-
"<strong>#{text}</strong>"
|
136
|
-
else
|
137
|
-
text
|
138
|
-
end
|
139
|
-
else
|
140
|
-
text # catchall, shouldn't be needed
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def self.format_issue_link(issue:)
|
145
|
-
# formats the link according to the output format we need
|
146
|
-
link = @jira_helper.url(issue: issue)
|
147
|
-
case @format
|
148
|
-
when "slack"
|
149
|
-
"*<#{link}|#{issue.key}>*: #{issue.summary}"
|
150
|
-
when "markdown"
|
151
|
-
"- **[#{issue.key}](#{link})**: #{issue.summary}"
|
152
|
-
when "html"
|
153
|
-
" - <strong><a href=\"#{link}\" target=\"_blank\">#{issue.key}</a><strong>: #{issue.summary}"
|
154
|
-
else
|
155
|
-
"- #{issue.key}: #{issue.summary} (#{link})"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def self.format_issues(label:, issues:)
|
160
|
-
[
|
161
|
-
style_text(text: "► #{label}", style: 'heading'),
|
162
|
-
issues.map { |issue| format_issue_link(issue: issue) }
|
163
|
-
].flatten!
|
164
|
-
end
|
165
|
-
|
166
|
-
def self.tickets(commits:, regex:)
|
167
|
-
commits
|
168
|
-
.to_enum(:scan, regex)
|
169
|
-
.map { $& }
|
170
|
-
.reject(&:empty?)
|
171
|
-
.uniq
|
172
|
-
end
|
173
|
-
|
174
|
-
def self.description
|
175
|
-
"It generates a release note based on the issues keys and descriptions found in the commits"
|
176
|
-
end
|
177
|
-
|
178
|
-
def self.authors
|
179
|
-
["Erick Martins"]
|
180
|
-
end
|
181
|
-
|
182
|
-
def self.return_value
|
183
|
-
# If your method provides a return value, you can describe here what it does
|
184
|
-
end
|
185
|
-
|
186
|
-
def self.details
|
187
|
-
# Optional:
|
188
|
-
"It generates a release note based on the issues keys and descriptions found in the commits"
|
189
|
-
end
|
190
|
-
|
191
|
-
def self.available_options
|
192
|
-
[
|
193
|
-
FastlaneCore::ConfigItem.new(
|
194
|
-
key: :tag_prefix,
|
195
|
-
description: "Match parameter of git describe. See man page of git describe for more info",
|
196
|
-
verify_block: proc do |value|
|
197
|
-
UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
|
198
|
-
end
|
199
|
-
),
|
200
|
-
FastlaneCore::ConfigItem.new(
|
201
|
-
key: :ticket_prefix,
|
202
|
-
env_name: 'FL_FIND_TICKETS_MATCHING',
|
203
|
-
description: 'regex to extract ticket numbers',
|
204
|
-
default_value: '[A-Z]+',
|
205
|
-
optional: true
|
206
|
-
),
|
207
|
-
FastlaneCore::ConfigItem.new(
|
208
|
-
key: :tag_version_match,
|
209
|
-
description: "To parse version number from tag name",
|
210
|
-
default_value: '\d+\.\d+\.\d+'
|
211
|
-
),
|
212
|
-
FastlaneCore::ConfigItem.new(
|
213
|
-
key: :validated_status,
|
214
|
-
env_name: 'FL_JIRA_VALIDATED_STATUS',
|
215
|
-
description: 'List of jira issues status already validated',
|
216
|
-
optional: false,
|
217
|
-
type: Array
|
218
|
-
),
|
219
|
-
FastlaneCore::ConfigItem.new(
|
220
|
-
key: :to_validate_status,
|
221
|
-
env_name: 'FL_JIRA_TO_VALIDATE_STATUS',
|
222
|
-
description: 'List of jira issues status to be validated',
|
223
|
-
optional: false,
|
224
|
-
type: Array
|
225
|
-
),
|
226
|
-
FastlaneCore::ConfigItem.new(
|
227
|
-
key: :format,
|
228
|
-
description: "You can use either markdown, slack, html or plain",
|
229
|
-
default_value: "markdown",
|
230
|
-
optional: true,
|
231
|
-
verify_block: proc do |value|
|
232
|
-
UI.user_error!("Invalid format! You can use either markdown, slack, html or plain") unless ['markdown', 'html', 'slack', 'plain'].include?(value)
|
233
|
-
end
|
234
|
-
),
|
235
|
-
|
236
|
-
# Jira Client options
|
237
|
-
FastlaneCore::ConfigItem.new(
|
238
|
-
key: :username,
|
239
|
-
env_name: 'FL_JIRA_USERNAME',
|
240
|
-
description: 'Jira user',
|
241
|
-
optional: false
|
242
|
-
),
|
243
|
-
FastlaneCore::ConfigItem.new(
|
244
|
-
key: :password,
|
245
|
-
env_name: 'FL_JIRA_PASSWORD',
|
246
|
-
description: 'Jira user password',
|
247
|
-
optional: false
|
248
|
-
),
|
249
|
-
FastlaneCore::ConfigItem.new(
|
250
|
-
key: :host,
|
251
|
-
env_name: 'FL_JIRA_HOST',
|
252
|
-
description: 'Jira location',
|
253
|
-
optional: false
|
254
|
-
),
|
255
|
-
FastlaneCore::ConfigItem.new(
|
256
|
-
key: :context_path,
|
257
|
-
env_name: 'FL_JIRA_CONTEXT_PATH',
|
258
|
-
description: 'Jira context path',
|
259
|
-
optional: true,
|
260
|
-
default_value: ''
|
261
|
-
),
|
262
|
-
FastlaneCore::ConfigItem.new(
|
263
|
-
key: :disable_ssl_verification,
|
264
|
-
env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
|
265
|
-
description: 'Jira SSL Verification mode',
|
266
|
-
optional: true,
|
267
|
-
default_value: false,
|
268
|
-
type: Boolean
|
269
|
-
),
|
270
|
-
FastlaneCore::ConfigItem.new(
|
271
|
-
key: :debug,
|
272
|
-
description: "True if you want to log out a debug info",
|
273
|
-
default_value: false,
|
274
|
-
type: Boolean,
|
275
|
-
optional: true
|
276
|
-
)
|
277
|
-
]
|
278
|
-
end
|
279
|
-
|
280
|
-
def self.is_supported?(platform)
|
281
|
-
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
282
|
-
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
283
|
-
#
|
284
|
-
# [:ios, :mac, :android].include?(platform)
|
285
|
-
true
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|