fastlane-plugin-semantic_release 1.19.1 → 1.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/semantic_release/actions/analyze_commits.rb +41 -98
- data/lib/fastlane/plugin/semantic_release/actions/conventional_changelog.rb +36 -97
- data/lib/fastlane/plugin/semantic_release/helper/semantic_release_helper.rb +37 -66
- data/lib/fastlane/plugin/semantic_release/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ce1113769c465612e01e3881aa8227c5c5bc9f20c91c7ae6cb47b8124a82ac8
|
|
4
|
+
data.tar.gz: 7330bf213de14b9fc2555c731069f55e78e725205212a2bbb80ca27380cbce0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1117593ee5dc4ea4097a6d2c761175977d464d9343a9c40c6f2451b37c053db2e9ef40b673aface8d2b5eb2a44c76e728be0e9fcf390c54d2e5350c56a37e0bc
|
|
7
|
+
data.tar.gz: b34d3e5504ad75f12f00a57f7f11da35d14a12326a2e2e990d428c6668a6485a71cc964a21f3654976fe26f72880ec78381b0c53c1cd2307f90a82eea9b97b30
|
|
@@ -19,7 +19,6 @@ module Fastlane
|
|
|
19
19
|
|
|
20
20
|
class AnalyzeCommitsAction < Action
|
|
21
21
|
def self.get_last_tag(params)
|
|
22
|
-
# Try to find the tag
|
|
23
22
|
command = "git describe --tags --match=#{params[:match]}"
|
|
24
23
|
Actions.sh(command, log: params[:debug])
|
|
25
24
|
rescue StandardError
|
|
@@ -42,25 +41,20 @@ module Fastlane
|
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def self.get_beginning_of_next_sprint(params)
|
|
45
|
-
# command to get first commit
|
|
46
44
|
git_command = "git rev-list --max-parents=0 HEAD"
|
|
47
|
-
|
|
48
45
|
tag = get_last_tag(match: params[:match], debug: params[:debug])
|
|
49
46
|
|
|
50
|
-
# if tag doesn't exist it get's first commit or fallback tag (v*.*.*)
|
|
51
47
|
if tag.empty?
|
|
52
48
|
UI.message("It couldn't match tag for #{params[:match]}. Check if first commit can be taken as a beginning of next release")
|
|
53
|
-
# If there is no tag found we taking the first commit of current branch
|
|
54
49
|
# Use tail -n 1 to handle repos with multiple root commits (e.g. merged histories)
|
|
55
|
-
UI.message("First commit of the branch is taken as a
|
|
50
|
+
UI.message("First commit of the branch is taken as a beginning of next release")
|
|
56
51
|
return {
|
|
57
52
|
hash: Actions.sh("#{git_command} | tail -n 1", log: params[:debug]).chomp
|
|
58
53
|
}
|
|
59
54
|
end
|
|
60
55
|
|
|
61
|
-
# Tag
|
|
62
|
-
#
|
|
63
|
-
# It can be also v2.3.4-5 if there is no commit after tag
|
|
56
|
+
# Tag format is v2.3.4-5-g7685948 (see git describe man page)
|
|
57
|
+
# Strip the git describe suffix (-<count>-g<hash>) to get the tag name
|
|
64
58
|
tag_name = tag
|
|
65
59
|
if tag.split('-').length >= 3
|
|
66
60
|
tag_name = tag.split('-')[0...-2].join('-').strip
|
|
@@ -72,18 +66,23 @@ module Fastlane
|
|
|
72
66
|
end
|
|
73
67
|
|
|
74
68
|
version = parsed_version[0]
|
|
75
|
-
|
|
76
|
-
hash = get_last_tag_hash(
|
|
77
|
-
tag_name: tag_name,
|
|
78
|
-
debug: params[:debug]
|
|
79
|
-
)
|
|
69
|
+
hash = get_last_tag_hash(tag_name: tag_name, debug: params[:debug])
|
|
80
70
|
|
|
81
71
|
UI.message("Found a tag #{tag_name} associated with version #{version}")
|
|
82
72
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
{ hash: hash, version: version }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.bump_version(major, minor, patch, commit)
|
|
77
|
+
if commit[:release] == "major" || commit[:is_breaking_change]
|
|
78
|
+
[major + 1, 0, 0]
|
|
79
|
+
elsif commit[:release] == "minor"
|
|
80
|
+
[major, minor + 1, 0]
|
|
81
|
+
elsif commit[:release] == "patch"
|
|
82
|
+
[major, minor, patch + 1]
|
|
83
|
+
else
|
|
84
|
+
[major, minor, patch]
|
|
85
|
+
end
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
def self.clamp_version(next_major, next_minor, next_patch, base_major, base_minor, base_patch)
|
|
@@ -99,52 +98,37 @@ module Fastlane
|
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
def self.is_releasable(params)
|
|
102
|
-
# Hash of the commit where is the last version
|
|
103
101
|
beginning = get_beginning_of_next_sprint(params)
|
|
104
102
|
|
|
105
103
|
unless beginning
|
|
106
|
-
UI.error('It could not find a
|
|
104
|
+
UI.error('It could not find a beginning of this sprint. How to fix this:')
|
|
107
105
|
UI.error('-- ensure there is only one commit with --max-parents=0 (this command should return one line: "git rev-list --max-parents=0 HEAD")')
|
|
108
|
-
UI.error('-- tell us
|
|
106
|
+
UI.error('-- tell us explicitly where the release starts by adding tag like this: vX.Y.Z (where X.Y.Z is version from which it starts computing next version number)')
|
|
109
107
|
return false
|
|
110
108
|
end
|
|
111
109
|
|
|
112
|
-
# Default last version
|
|
113
110
|
version = beginning[:version] || '0.0.0'
|
|
114
|
-
# If the tag is not found we are taking HEAD as reference
|
|
115
111
|
hash = beginning[:hash] || 'HEAD'
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
next_major = (version.split('.')[0] || 0).to_i
|
|
119
|
-
next_minor = (version.split('.')[1] || 0).to_i
|
|
120
|
-
next_patch = (version.split('.')[2] || 0).to_i
|
|
121
|
-
|
|
122
|
-
# Save base version for potential clamping
|
|
113
|
+
next_major, next_minor, next_patch = Helper::SemanticReleaseHelper.parse_semver(version)
|
|
123
114
|
base_major = next_major
|
|
124
115
|
base_minor = next_minor
|
|
125
116
|
base_patch = next_patch
|
|
126
117
|
|
|
127
118
|
is_next_version_compatible_with_codepush = true
|
|
128
119
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
hash: hash,
|
|
132
|
-
debug: params[:debug]
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
UI.message("Found #{splitted.length} commits since last release")
|
|
136
|
-
releases = params[:releases]
|
|
120
|
+
commits = get_commits_from_hash(hash: hash, debug: params[:debug])
|
|
121
|
+
UI.message("Found #{commits.length} commits since last release")
|
|
137
122
|
|
|
138
123
|
format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
|
|
139
|
-
|
|
124
|
+
commits.each do |line|
|
|
140
125
|
parts = line.split("|")
|
|
141
126
|
subject = parts[0].to_s.strip
|
|
142
|
-
|
|
143
|
-
# type: subject (fix: app crash - for example)
|
|
127
|
+
|
|
144
128
|
commit = Helper::SemanticReleaseHelper.parse_commit(
|
|
145
129
|
commit_subject: subject,
|
|
146
130
|
commit_body: parts[1],
|
|
147
|
-
releases: releases,
|
|
131
|
+
releases: params[:releases],
|
|
148
132
|
pattern: format_pattern
|
|
149
133
|
)
|
|
150
134
|
|
|
@@ -154,41 +138,25 @@ module Fastlane
|
|
|
154
138
|
ignore_scopes: params[:ignore_scopes]
|
|
155
139
|
)
|
|
156
140
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
next_minor = 0
|
|
160
|
-
next_patch = 0
|
|
161
|
-
elsif commit[:release] == "minor"
|
|
162
|
-
next_minor += 1
|
|
163
|
-
next_patch = 0
|
|
164
|
-
elsif commit[:release] == "patch"
|
|
165
|
-
next_patch += 1
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
unless commit[:is_codepush_friendly]
|
|
169
|
-
is_next_version_compatible_with_codepush = false
|
|
170
|
-
end
|
|
141
|
+
next_major, next_minor, next_patch = bump_version(next_major, next_minor, next_patch, commit)
|
|
142
|
+
is_next_version_compatible_with_codepush = false unless commit[:is_codepush_friendly]
|
|
171
143
|
|
|
172
144
|
next_version = "#{next_major}.#{next_minor}.#{next_patch}"
|
|
173
145
|
UI.message("#{next_version}: #{subject}") if params[:show_version_path]
|
|
174
146
|
end
|
|
175
147
|
|
|
176
|
-
# When bump_per_commit is false, clamp to single increment
|
|
177
148
|
unless params[:bump_per_commit]
|
|
178
149
|
next_major, next_minor, next_patch = clamp_version(next_major, next_minor, next_patch, base_major, base_minor, base_patch)
|
|
179
150
|
end
|
|
180
151
|
|
|
181
152
|
next_version = "#{next_major}.#{next_minor}.#{next_patch}"
|
|
182
|
-
|
|
183
153
|
is_next_version_releasable = Helper::SemanticReleaseHelper.semver_gt(next_version, version)
|
|
184
154
|
|
|
185
155
|
Actions.lane_context[SharedValues::RELEASE_ANALYZED] = true
|
|
186
156
|
Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_HIGHER] = is_next_version_releasable
|
|
187
157
|
Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH] = is_next_version_compatible_with_codepush
|
|
188
|
-
# Last release analysis
|
|
189
158
|
Actions.lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = hash
|
|
190
159
|
Actions.lane_context[SharedValues::RELEASE_LAST_VERSION] = version
|
|
191
|
-
# Next release analysis
|
|
192
160
|
Actions.lane_context[SharedValues::RELEASE_NEXT_MAJOR_VERSION] = next_major
|
|
193
161
|
Actions.lane_context[SharedValues::RELEASE_NEXT_MINOR_VERSION] = next_minor
|
|
194
162
|
Actions.lane_context[SharedValues::RELEASE_NEXT_PATCH_VERSION] = next_patch
|
|
@@ -202,47 +170,30 @@ module Fastlane
|
|
|
202
170
|
|
|
203
171
|
def self.is_codepush_friendly(params)
|
|
204
172
|
git_command = "git rev-list --max-parents=0 HEAD"
|
|
205
|
-
# Begining of the branch is taken for codepush analysis
|
|
206
173
|
# Use tail -n 1 to handle repos with multiple root commits (e.g. merged histories)
|
|
207
174
|
hash = Actions.sh("#{git_command} | tail -n 1", log: params[:debug]).chomp
|
|
208
175
|
next_major = 0
|
|
209
176
|
next_minor = 0
|
|
210
177
|
next_patch = 0
|
|
211
|
-
base_major =
|
|
212
|
-
base_minor =
|
|
213
|
-
base_patch =
|
|
178
|
+
base_major = 0
|
|
179
|
+
base_minor = 0
|
|
180
|
+
base_patch = 0
|
|
214
181
|
last_incompatible_codepush_version = '0.0.0'
|
|
215
182
|
|
|
216
|
-
|
|
217
|
-
splitted = get_commits_from_hash(
|
|
218
|
-
hash: hash,
|
|
219
|
-
debug: params[:debug]
|
|
220
|
-
)
|
|
221
|
-
releases = params[:releases]
|
|
222
|
-
codepush_friendly = params[:codepush_friendly]
|
|
183
|
+
commits = get_commits_from_hash(hash: hash, debug: params[:debug])
|
|
223
184
|
|
|
224
185
|
format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
# type: subject (fix: app crash - for example)
|
|
186
|
+
commits.each do |line|
|
|
187
|
+
parts = line.split("|")
|
|
228
188
|
commit = Helper::SemanticReleaseHelper.parse_commit(
|
|
229
|
-
commit_subject:
|
|
230
|
-
commit_body:
|
|
231
|
-
releases: releases,
|
|
189
|
+
commit_subject: parts[0],
|
|
190
|
+
commit_body: parts[1],
|
|
191
|
+
releases: params[:releases],
|
|
232
192
|
pattern: format_pattern,
|
|
233
|
-
codepush_friendly: codepush_friendly
|
|
193
|
+
codepush_friendly: params[:codepush_friendly]
|
|
234
194
|
)
|
|
235
195
|
|
|
236
|
-
|
|
237
|
-
next_major += 1
|
|
238
|
-
next_minor = 0
|
|
239
|
-
next_patch = 0
|
|
240
|
-
elsif commit[:release] == "minor"
|
|
241
|
-
next_minor += 1
|
|
242
|
-
next_patch = 0
|
|
243
|
-
elsif commit[:release] == "patch"
|
|
244
|
-
next_patch += 1
|
|
245
|
-
end
|
|
196
|
+
next_major, next_minor, next_patch = bump_version(next_major, next_minor, next_patch, commit)
|
|
246
197
|
|
|
247
198
|
unless commit[:is_codepush_friendly]
|
|
248
199
|
last_incompatible_codepush_version = "#{next_major}.#{next_minor}.#{next_patch}"
|
|
@@ -268,7 +219,7 @@ module Fastlane
|
|
|
268
219
|
#####################################################
|
|
269
220
|
|
|
270
221
|
def self.description
|
|
271
|
-
"Finds a tag of last release and
|
|
222
|
+
"Finds a tag of last release and determines version of next release"
|
|
272
223
|
end
|
|
273
224
|
|
|
274
225
|
def self.details
|
|
@@ -276,9 +227,6 @@ module Fastlane
|
|
|
276
227
|
end
|
|
277
228
|
|
|
278
229
|
def self.available_options
|
|
279
|
-
# Define all options your action supports.
|
|
280
|
-
|
|
281
|
-
# Below a few examples
|
|
282
230
|
[
|
|
283
231
|
FastlaneCore::ConfigItem.new(
|
|
284
232
|
key: :match,
|
|
@@ -372,11 +320,9 @@ module Fastlane
|
|
|
372
320
|
end
|
|
373
321
|
|
|
374
322
|
def self.output
|
|
375
|
-
# Define the shared values you are going to provide
|
|
376
|
-
# Example
|
|
377
323
|
[
|
|
378
324
|
['RELEASE_ANALYZED', 'True if commits were analyzed.'],
|
|
379
|
-
['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher
|
|
325
|
+
['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher than last version'],
|
|
380
326
|
['RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH', 'True if next version is compatible with codepush'],
|
|
381
327
|
['RELEASE_LAST_TAG_HASH', 'Hash of commit that is tagged as a last version'],
|
|
382
328
|
['RELEASE_LAST_VERSION', 'Last version number - parsed from last tag.'],
|
|
@@ -390,17 +336,14 @@ module Fastlane
|
|
|
390
336
|
end
|
|
391
337
|
|
|
392
338
|
def self.return_value
|
|
393
|
-
|
|
394
|
-
"Returns true if the next version is higher then the last version"
|
|
339
|
+
"Returns true if the next version is higher than the last version"
|
|
395
340
|
end
|
|
396
341
|
|
|
397
342
|
def self.authors
|
|
398
|
-
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
|
|
399
343
|
["xotahal"]
|
|
400
344
|
end
|
|
401
345
|
|
|
402
346
|
def self.is_supported?(platform)
|
|
403
|
-
# you can do things like
|
|
404
347
|
true
|
|
405
348
|
end
|
|
406
349
|
end
|
|
@@ -17,168 +17,115 @@ module Fastlane
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def self.run(params)
|
|
20
|
-
# Get next version number from shared values
|
|
21
20
|
analyzed = lane_context[SharedValues::RELEASE_ANALYZED]
|
|
22
21
|
|
|
23
|
-
# If analyze commits action was not run there will be no version in shared
|
|
24
|
-
# values. We need to run the action to get next version number
|
|
25
22
|
unless analyzed
|
|
26
23
|
UI.user_error!("Release hasn't been analyzed yet. Run analyze_commits action first please.")
|
|
27
|
-
# version = other_action.analyze_commits(match: params[:match])
|
|
28
24
|
end
|
|
29
25
|
|
|
30
26
|
last_tag_hash = lane_context[SharedValues::RELEASE_LAST_TAG_HASH]
|
|
31
27
|
version = lane_context[SharedValues::RELEASE_NEXT_VERSION]
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
commits = get_commits_from_hash(
|
|
35
|
-
hash: last_tag_hash,
|
|
36
|
-
debug: params[:debug]
|
|
37
|
-
)
|
|
29
|
+
commits = get_commits_from_hash(hash: last_tag_hash, debug: params[:debug])
|
|
38
30
|
parsed = parse_commits(commits, params)
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
format = params[:format]
|
|
42
|
-
|
|
43
|
-
note_builder(format, parsed, version, commit_url, params)
|
|
32
|
+
note_builder(params[:format], parsed, version, params[:commit_url], params)
|
|
44
33
|
end
|
|
45
34
|
|
|
46
35
|
def self.note_builder(format, commits, version, commit_url, params)
|
|
47
36
|
sections = params[:sections]
|
|
48
|
-
|
|
49
37
|
result = ""
|
|
50
38
|
|
|
51
|
-
# Begining of release notes
|
|
52
39
|
if params[:display_title] == true
|
|
53
40
|
title = version
|
|
54
41
|
title += " #{params[:title]}" if params[:title]
|
|
55
42
|
title += " (#{Date.today})"
|
|
56
43
|
|
|
57
|
-
result = style_text(title, format,
|
|
58
|
-
result += "\n\n"
|
|
44
|
+
result = "#{style_text(title, format, 'title')}\n\n"
|
|
59
45
|
end
|
|
60
46
|
|
|
61
47
|
params[:order].each do |type|
|
|
62
|
-
# write section only if there is at least one commit
|
|
63
48
|
next if commits.none? { |commit| commit[:type] == type }
|
|
64
49
|
|
|
65
|
-
result += style_text(sections[type.to_sym], format,
|
|
66
|
-
result += "\n"
|
|
50
|
+
result += "#{style_text(sections[type.to_sym], format, 'heading')}\n"
|
|
67
51
|
|
|
68
52
|
commits.each do |commit|
|
|
69
53
|
next if commit[:type] != type || commit[:is_merge]
|
|
70
54
|
|
|
71
55
|
result += "-"
|
|
72
|
-
|
|
73
|
-
unless commit[:scope].nil?
|
|
74
|
-
formatted_text = style_text("#{commit[:scope]}:", format, "bold").to_s
|
|
75
|
-
result += " #{formatted_text}"
|
|
76
|
-
end
|
|
77
|
-
|
|
56
|
+
result += " #{style_text("#{commit[:scope]}:", format, 'bold')}" unless commit[:scope].nil?
|
|
78
57
|
result += " #{commit[:subject]}"
|
|
79
|
-
|
|
80
|
-
if params[:
|
|
81
|
-
styled_link = build_commit_link(commit, commit_url, format).to_s
|
|
82
|
-
result += " (#{styled_link})"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
if params[:display_author]
|
|
86
|
-
result += " - #{commit[:author_name]}"
|
|
87
|
-
end
|
|
88
|
-
|
|
58
|
+
result += " (#{build_commit_link(commit, commit_url, format)})" if params[:display_links] == true
|
|
59
|
+
result += " - #{commit[:author_name]}" if params[:display_author]
|
|
89
60
|
result += "\n"
|
|
90
61
|
end
|
|
91
62
|
result += "\n"
|
|
92
63
|
end
|
|
93
64
|
|
|
94
65
|
if commits.any? { |commit| commit[:is_breaking_change] == true }
|
|
95
|
-
result += style_text(
|
|
96
|
-
result += "\n"
|
|
66
|
+
result += "#{style_text('BREAKING CHANGES', format, 'heading')}\n"
|
|
97
67
|
|
|
98
68
|
commits.each do |commit|
|
|
99
69
|
next unless commit[:is_breaking_change]
|
|
100
70
|
|
|
101
|
-
result += "- #{commit[:breaking_change]}"
|
|
102
|
-
|
|
103
|
-
if params[:
|
|
104
|
-
styled_link = build_commit_link(commit, commit_url, format).to_s
|
|
105
|
-
result += " (#{styled_link})"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
if params[:display_author]
|
|
109
|
-
result += " - #{commit[:author_name]}"
|
|
110
|
-
end
|
|
111
|
-
|
|
71
|
+
result += "- #{commit[:breaking_change]}"
|
|
72
|
+
result += " (#{build_commit_link(commit, commit_url, format)})" if params[:display_links] == true
|
|
73
|
+
result += " - #{commit[:author_name]}" if params[:display_author]
|
|
112
74
|
result += "\n"
|
|
113
75
|
end
|
|
114
76
|
|
|
115
77
|
result += "\n"
|
|
116
78
|
end
|
|
117
79
|
|
|
118
|
-
# Trim any trailing newlines
|
|
119
80
|
result.rstrip!
|
|
120
81
|
end
|
|
121
82
|
|
|
122
83
|
def self.style_text(text, format, style)
|
|
123
|
-
# formats the text according to the style we're looking to use
|
|
124
|
-
|
|
125
|
-
# Skips all styling
|
|
126
84
|
case style
|
|
127
85
|
when "title"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
else
|
|
133
|
-
text
|
|
86
|
+
case format
|
|
87
|
+
when "markdown" then "# #{text}"
|
|
88
|
+
when "slack" then "*#{text}*"
|
|
89
|
+
else text
|
|
134
90
|
end
|
|
135
91
|
when "heading"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
else
|
|
141
|
-
"#{text}:"
|
|
92
|
+
case format
|
|
93
|
+
when "markdown" then "### #{text}"
|
|
94
|
+
when "slack" then "*#{text}*"
|
|
95
|
+
else "#{text}:"
|
|
142
96
|
end
|
|
143
97
|
when "bold"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
else
|
|
149
|
-
text
|
|
98
|
+
case format
|
|
99
|
+
when "markdown" then "**#{text}**"
|
|
100
|
+
when "slack" then "*#{text}*"
|
|
101
|
+
else text
|
|
150
102
|
end
|
|
151
103
|
else
|
|
152
|
-
text
|
|
104
|
+
text
|
|
153
105
|
end
|
|
154
106
|
end
|
|
155
107
|
|
|
156
108
|
def self.build_commit_link(commit, commit_url, format)
|
|
157
|
-
# formats the link according to the output format we need
|
|
158
109
|
short_hash = commit[:short_hash]
|
|
159
|
-
|
|
160
|
-
url = "#{commit_url}/#{hash}"
|
|
110
|
+
url = "#{commit_url}/#{commit[:hash]}"
|
|
161
111
|
|
|
162
112
|
case format
|
|
163
|
-
when "slack"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"[#{short_hash}](#{url})"
|
|
167
|
-
else
|
|
168
|
-
url
|
|
113
|
+
when "slack" then "<#{url}|#{short_hash}>"
|
|
114
|
+
when "markdown" then "[#{short_hash}](#{url})"
|
|
115
|
+
else url
|
|
169
116
|
end
|
|
170
117
|
end
|
|
171
118
|
|
|
172
119
|
def self.parse_commits(commits, params)
|
|
173
120
|
parsed = []
|
|
174
|
-
# %s|%b|%H|%h|%an|%at
|
|
175
121
|
format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
|
|
122
|
+
|
|
176
123
|
commits.each do |line|
|
|
177
|
-
|
|
124
|
+
parts = line.split("|")
|
|
178
125
|
|
|
179
126
|
commit = Helper::SemanticReleaseHelper.parse_commit(
|
|
180
|
-
commit_subject:
|
|
181
|
-
commit_body:
|
|
127
|
+
commit_subject: parts[0],
|
|
128
|
+
commit_body: parts[1],
|
|
182
129
|
pattern: format_pattern
|
|
183
130
|
)
|
|
184
131
|
|
|
@@ -188,10 +135,10 @@ module Fastlane
|
|
|
188
135
|
ignore_scopes: params[:ignore_scopes]
|
|
189
136
|
)
|
|
190
137
|
|
|
191
|
-
commit[:hash] =
|
|
192
|
-
commit[:short_hash] =
|
|
193
|
-
commit[:author_name] =
|
|
194
|
-
commit[:commit_date] =
|
|
138
|
+
commit[:hash] = parts[2]
|
|
139
|
+
commit[:short_hash] = parts[3]
|
|
140
|
+
commit[:author_name] = parts[4]
|
|
141
|
+
commit[:commit_date] = parts[5]
|
|
195
142
|
|
|
196
143
|
parsed.push(commit)
|
|
197
144
|
end
|
|
@@ -212,9 +159,6 @@ module Fastlane
|
|
|
212
159
|
end
|
|
213
160
|
|
|
214
161
|
def self.available_options
|
|
215
|
-
# Define all options your action supports.
|
|
216
|
-
|
|
217
|
-
# Below a few examples
|
|
218
162
|
[
|
|
219
163
|
FastlaneCore::ConfigItem.new(
|
|
220
164
|
key: :format,
|
|
@@ -301,23 +245,18 @@ module Fastlane
|
|
|
301
245
|
end
|
|
302
246
|
|
|
303
247
|
def self.output
|
|
304
|
-
# Define the shared values you are going to provide
|
|
305
|
-
# Example
|
|
306
248
|
[]
|
|
307
249
|
end
|
|
308
250
|
|
|
309
251
|
def self.return_value
|
|
310
|
-
# If your method provides a return value, you can describe here what it does
|
|
311
252
|
"Returns generated release notes as a string"
|
|
312
253
|
end
|
|
313
254
|
|
|
314
255
|
def self.authors
|
|
315
|
-
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
|
|
316
256
|
["xotahal"]
|
|
317
257
|
end
|
|
318
258
|
|
|
319
259
|
def self.is_supported?(platform)
|
|
320
|
-
# you can do things like
|
|
321
260
|
true
|
|
322
261
|
end
|
|
323
262
|
end
|
|
@@ -5,16 +5,20 @@ module Fastlane
|
|
|
5
5
|
|
|
6
6
|
module Helper
|
|
7
7
|
class SemanticReleaseHelper
|
|
8
|
+
FORMAT_PATTERNS = {
|
|
9
|
+
"default" => /^(docs|fix|feat|chore|style|refactor|perf|test)(?:\((.*)\))?(!?): (.*)/i,
|
|
10
|
+
"angular" => /^(\w*)(?:\((.*)\))?(): (.*)/
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
8
13
|
def self.format_patterns
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
FORMAT_PATTERNS
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.parse_semver(version_string)
|
|
18
|
+
parts = version_string.split('.')
|
|
19
|
+
[(parts[0] || 0).to_i, (parts[1] || 0).to_i, (parts[2] || 0).to_i]
|
|
13
20
|
end
|
|
14
21
|
|
|
15
|
-
# class methods that you define here become available in your action
|
|
16
|
-
# as `Helper::SemanticReleaseHelper.your_method`
|
|
17
|
-
#
|
|
18
22
|
def self.git_log(params)
|
|
19
23
|
command = "git log --pretty='#{params[:pretty]}' --reverse #{params[:start]}..HEAD"
|
|
20
24
|
Actions.sh(command, log: params[:debug]).chomp
|
|
@@ -25,13 +29,10 @@ module Fastlane
|
|
|
25
29
|
scopes_to_include = params[:include_scopes]
|
|
26
30
|
scopes_to_ignore = params[:ignore_scopes]
|
|
27
31
|
|
|
28
|
-
unless scopes_to_include.empty?
|
|
29
|
-
|
|
30
|
-
end
|
|
32
|
+
return !scopes_to_include.include?(commit_scope) unless scopes_to_include.empty?
|
|
33
|
+
return scopes_to_ignore.include?(commit_scope) unless commit_scope.nil?
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
return scopes_to_ignore.include?(commit_scope)
|
|
34
|
-
end
|
|
35
|
+
false
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def self.parse_commit(params)
|
|
@@ -40,8 +41,6 @@ module Fastlane
|
|
|
40
41
|
releases = params[:releases]
|
|
41
42
|
codepush_friendly = params[:codepush_friendly]
|
|
42
43
|
pattern = params[:pattern]
|
|
43
|
-
breaking_change_pattern = /BREAKING CHANGES?: (.*)/
|
|
44
|
-
codepush_pattern = /codepush?: (.*)/
|
|
45
44
|
|
|
46
45
|
matched = commit_subject.match(pattern)
|
|
47
46
|
result = {
|
|
@@ -51,67 +50,39 @@ module Fastlane
|
|
|
51
50
|
type: 'no_type'
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
type = matched[1].downcase
|
|
56
|
-
scope = matched[2]
|
|
53
|
+
return result if matched.nil?
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
unless releases.nil?
|
|
65
|
-
result[:release] = releases[type.to_sym]
|
|
66
|
-
end
|
|
67
|
-
unless codepush_friendly.nil?
|
|
68
|
-
result[:is_codepush_friendly] = codepush_friendly.include?(type)
|
|
69
|
-
end
|
|
55
|
+
type = matched[1].downcase
|
|
56
|
+
result[:is_valid] = true
|
|
57
|
+
result[:type] = type
|
|
58
|
+
result[:scope] = matched[2]
|
|
59
|
+
result[:has_exclamation_mark] = matched[3] == '!'
|
|
60
|
+
result[:subject] = matched[4]
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
unless breaking_change_matched.nil?
|
|
76
|
-
result[:is_breaking_change] = true
|
|
77
|
-
result[:breaking_change] = breaking_change_matched[1]
|
|
78
|
-
end
|
|
79
|
-
unless codepush_matched.nil?
|
|
80
|
-
result[:is_codepush_friendly] = codepush_matched[1] == 'ok'
|
|
81
|
-
end
|
|
82
|
-
end
|
|
62
|
+
if result[:has_exclamation_mark]
|
|
63
|
+
result[:is_breaking_change] = true
|
|
64
|
+
result[:breaking_change] = matched[4]
|
|
83
65
|
end
|
|
84
66
|
|
|
85
|
-
result
|
|
86
|
-
|
|
67
|
+
result[:release] = releases[type.to_sym] unless releases.nil?
|
|
68
|
+
result[:is_codepush_friendly] = codepush_friendly.include?(type) unless codepush_friendly.nil?
|
|
87
69
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
second_patch = (second.split('.')[2] || 0).to_i
|
|
96
|
-
|
|
97
|
-
# Check if next version is higher then last version
|
|
98
|
-
if first_major > second_major
|
|
99
|
-
return true
|
|
100
|
-
elsif first_major == second_major
|
|
101
|
-
if first_minor > second_minor
|
|
102
|
-
return true
|
|
103
|
-
elsif first_minor == second_minor
|
|
104
|
-
if first_patch > second_patch
|
|
105
|
-
return true
|
|
106
|
-
end
|
|
70
|
+
unless commit_body.nil?
|
|
71
|
+
breaking_match = commit_body.match(/BREAKING CHANGES?: (.*)/)
|
|
72
|
+
codepush_match = commit_body.match(/codepush?: (.*)/)
|
|
73
|
+
|
|
74
|
+
if breaking_match
|
|
75
|
+
result[:is_breaking_change] = true
|
|
76
|
+
result[:breaking_change] = breaking_match[1]
|
|
107
77
|
end
|
|
78
|
+
result[:is_codepush_friendly] = (codepush_match[1] == 'ok') if codepush_match
|
|
108
79
|
end
|
|
109
80
|
|
|
110
|
-
|
|
81
|
+
result
|
|
111
82
|
end
|
|
112
83
|
|
|
113
|
-
def self.
|
|
114
|
-
|
|
84
|
+
def self.semver_gt(first, second)
|
|
85
|
+
(parse_semver(first) <=> parse_semver(second)) == 1
|
|
115
86
|
end
|
|
116
87
|
end
|
|
117
88
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
module Fastlane module SemanticRelease VERSION = "1.19.
|
|
1
|
+
module Fastlane module SemanticRelease VERSION = "1.19.3" end end
|