fastlane-plugin-semantic_release 1.12.0 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/semantic_release/actions/analyze_commits.rb +92 -35
- data/lib/fastlane/plugin/semantic_release/actions/conventional_changelog.rb +22 -2
- data/lib/fastlane/plugin/semantic_release/helper/semantic_release_helper.rb +14 -0
- data/lib/fastlane/plugin/semantic_release/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfdd6b224d265922b3de9f42697de102ceacca38c4222e21295ace3e695c204c
|
4
|
+
data.tar.gz: cd348da86de7b4eba45d92672b67f6ce2af63ddd441b0a6d187296c9c9a5f8e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f91ea3be74683aeca782926fd80ca13e6f43ba1a6814cc89f76c055cc3e0b57183f885fc47ee97bfaac6cd8592cb02d0c1298ed57885ca4464801b5e8bbdcb6
|
7
|
+
data.tar.gz: e7d77b750b04093063de46eb83ba151b4a600e990c8e3e14bf97e5c0e548262f0a515b3b348a643de6fdf6877198889a2a0947947079579cf80233cfa19bc2fe
|
@@ -6,6 +6,7 @@ module Fastlane
|
|
6
6
|
module SharedValues
|
7
7
|
RELEASE_ANALYZED = :RELEASE_ANALYZED
|
8
8
|
RELEASE_IS_NEXT_VERSION_HIGHER = :RELEASE_IS_NEXT_VERSION_HIGHER
|
9
|
+
RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH = :RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH
|
9
10
|
RELEASE_LAST_TAG_HASH = :RELEASE_LAST_TAG_HASH
|
10
11
|
RELEASE_LAST_VERSION = :RELEASE_LAST_VERSION
|
11
12
|
RELEASE_NEXT_MAJOR_VERSION = :RELEASE_NEXT_MAJOR_VERSION
|
@@ -40,47 +41,85 @@ module Fastlane
|
|
40
41
|
commits.split("|>")
|
41
42
|
end
|
42
43
|
|
43
|
-
def self.
|
44
|
-
#
|
45
|
-
|
46
|
-
hash = 'HEAD'
|
47
|
-
# Default last version
|
48
|
-
version = '0.0.0'
|
44
|
+
def self.get_beginning_of_next_sprint(params)
|
45
|
+
# command to get first commit
|
46
|
+
git_command = "git rev-list --max-parents=0 HEAD"
|
49
47
|
|
50
|
-
tag = get_last_tag(
|
51
|
-
match: params[:match],
|
52
|
-
debug: params[:debug]
|
53
|
-
)
|
48
|
+
tag = get_last_tag(match: params[:match], debug: params[:debug])
|
54
49
|
|
50
|
+
# if tag doesn't exist it get's first commit or fallback tag (v*.*.*)
|
55
51
|
if tag.empty?
|
56
|
-
UI.message("
|
52
|
+
UI.message("It couldn't match tag for #{params[:match]}. Check if first commit can be taken as a beginning of next release")
|
57
53
|
# If there is no tag found we taking the first commit of current branch
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
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.")
|
54
|
+
hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
|
55
|
+
|
56
|
+
if hash_lines.to_i == 1
|
57
|
+
UI.message("First commit of the branch is taken as a begining of next release")
|
58
|
+
return {
|
59
|
+
# here we know this command will return 1 line
|
60
|
+
hash: Actions.sh(git_command, log: params[:debug]).chomp
|
61
|
+
}
|
67
62
|
end
|
68
63
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
64
|
+
unless params[:prevent_tag_fallback]
|
65
|
+
# neither matched tag and first hash could be used - as fallback we try vX.Y.Z
|
66
|
+
UI.message("It couldn't match tag for #{params[:match]} and couldn't use first commit. Check if tag vX.Y.Z can be taken as a begining of next release")
|
67
|
+
tag = get_last_tag(match: "v*", debug: params[:debug])
|
68
|
+
end
|
69
|
+
|
70
|
+
# even fallback tag doesn't work
|
71
|
+
if tag.empty?
|
72
|
+
return false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Tag's format is v2.3.4-5-g7685948
|
77
|
+
# See git describe man page for more info
|
78
|
+
tag_name = tag.split('-')[0...-2].join('-').strip
|
79
|
+
parsed_version = tag_name.match(params[:tag_version_match])
|
80
|
+
|
81
|
+
if parsed_version.nil?
|
82
|
+
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.")
|
83
|
+
end
|
84
|
+
|
85
|
+
version = parsed_version[0]
|
86
|
+
# Get a hash of last version tag
|
87
|
+
hash = get_last_tag_hash(
|
88
|
+
tag_name: tag_name,
|
89
|
+
debug: params[:debug]
|
90
|
+
)
|
91
|
+
|
92
|
+
UI.message("Found a tag #{tag_name} associated with version #{version}")
|
93
|
+
|
94
|
+
return {
|
95
|
+
hash: hash,
|
96
|
+
version: version
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.is_releasable(params)
|
101
|
+
# Hash of the commit where is the last version
|
102
|
+
beginning = get_beginning_of_next_sprint(params)
|
75
103
|
|
76
|
-
|
104
|
+
unless beginning
|
105
|
+
UI.error('It could not find a begining of this sprint. How to fix this:')
|
106
|
+
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")')
|
107
|
+
UI.error('-- tell us explicitely 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)')
|
108
|
+
return false
|
77
109
|
end
|
78
110
|
|
111
|
+
# Default last version
|
112
|
+
version = beginning[:version] || '0.0.0'
|
113
|
+
# If the tag is not found we are taking HEAD as reference
|
114
|
+
hash = beginning[:hash] || 'HEAD'
|
115
|
+
|
79
116
|
# converts last version string to the int numbers
|
80
117
|
next_major = (version.split('.')[0] || 0).to_i
|
81
118
|
next_minor = (version.split('.')[1] || 0).to_i
|
82
119
|
next_patch = (version.split('.')[2] || 0).to_i
|
83
120
|
|
121
|
+
is_next_version_compatible_with_codepush = true
|
122
|
+
|
84
123
|
# Get commits log between last version and head
|
85
124
|
splitted = get_commits_from_hash(
|
86
125
|
hash: hash,
|
@@ -103,13 +142,11 @@ module Fastlane
|
|
103
142
|
pattern: format_pattern
|
104
143
|
)
|
105
144
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
next if scopes_to_ignore.include?(scope) #=> true
|
112
|
-
end
|
145
|
+
next if Helper::SemanticReleaseHelper.should_exclude_commit(
|
146
|
+
commit_scope: commit[:scope],
|
147
|
+
include_scopes: params[:include_scopes],
|
148
|
+
ignore_scopes: params[:ignore_scopes]
|
149
|
+
)
|
113
150
|
|
114
151
|
if commit[:release] == "major" || commit[:is_breaking_change]
|
115
152
|
next_major += 1
|
@@ -122,6 +159,10 @@ module Fastlane
|
|
122
159
|
next_patch += 1
|
123
160
|
end
|
124
161
|
|
162
|
+
unless commit[:is_codepush_friendly]
|
163
|
+
is_next_version_compatible_with_codepush = false
|
164
|
+
end
|
165
|
+
|
125
166
|
next_version = "#{next_major}.#{next_minor}.#{next_patch}"
|
126
167
|
UI.message("#{next_version}: #{subject}") if params[:show_version_path]
|
127
168
|
end
|
@@ -132,6 +173,7 @@ module Fastlane
|
|
132
173
|
|
133
174
|
Actions.lane_context[SharedValues::RELEASE_ANALYZED] = true
|
134
175
|
Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_HIGHER] = is_next_version_releasable
|
176
|
+
Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH] = is_next_version_compatible_with_codepush
|
135
177
|
# Last release analysis
|
136
178
|
Actions.lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = hash
|
137
179
|
Actions.lane_context[SharedValues::RELEASE_LAST_VERSION] = version
|
@@ -148,7 +190,7 @@ module Fastlane
|
|
148
190
|
end
|
149
191
|
|
150
192
|
def self.is_codepush_friendly(params)
|
151
|
-
git_command =
|
193
|
+
git_command = "git rev-list --max-parents=0 HEAD"
|
152
194
|
# Begining of the branch is taken for codepush analysis
|
153
195
|
hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
|
154
196
|
hash = Actions.sh(git_command, log: params[:debug]).chomp
|
@@ -273,6 +315,20 @@ module Fastlane
|
|
273
315
|
description: "To parse version number from tag name",
|
274
316
|
default_value: '\d+\.\d+\.\d+'
|
275
317
|
),
|
318
|
+
FastlaneCore::ConfigItem.new(
|
319
|
+
key: :prevent_tag_fallback,
|
320
|
+
description: "Prevent tag from falling back to vX.Y.Z when there is no match",
|
321
|
+
default_value: false,
|
322
|
+
type: Boolean,
|
323
|
+
optional: true
|
324
|
+
),
|
325
|
+
FastlaneCore::ConfigItem.new(
|
326
|
+
key: :include_scopes,
|
327
|
+
description: "To only include certain scopes when calculating releases",
|
328
|
+
default_value: [],
|
329
|
+
type: Array,
|
330
|
+
optional: true
|
331
|
+
),
|
276
332
|
FastlaneCore::ConfigItem.new(
|
277
333
|
key: :ignore_scopes,
|
278
334
|
description: "To ignore certain scopes when calculating releases",
|
@@ -303,6 +359,7 @@ module Fastlane
|
|
303
359
|
[
|
304
360
|
['RELEASE_ANALYZED', 'True if commits were analyzed.'],
|
305
361
|
['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher then last version'],
|
362
|
+
['RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH', 'True if next version is compatible with codepush'],
|
306
363
|
['RELEASE_LAST_TAG_HASH', 'Hash of commit that is tagged as a last version'],
|
307
364
|
['RELEASE_LAST_VERSION', 'Last version number - parsed from last tag.'],
|
308
365
|
['RELEASE_NEXT_MAJOR_VERSION', 'Major number of the next version'],
|
@@ -35,7 +35,7 @@ module Fastlane
|
|
35
35
|
hash: last_tag_hash,
|
36
36
|
debug: params[:debug]
|
37
37
|
)
|
38
|
-
parsed = parse_commits(commits)
|
38
|
+
parsed = parse_commits(commits, params)
|
39
39
|
|
40
40
|
commit_url = params[:commit_url]
|
41
41
|
format = params[:format]
|
@@ -172,7 +172,7 @@ module Fastlane
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
def self.parse_commits(commits)
|
175
|
+
def self.parse_commits(commits, params)
|
176
176
|
parsed = []
|
177
177
|
# %s|%b|%H|%h|%an|%at
|
178
178
|
format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
|
@@ -185,6 +185,12 @@ module Fastlane
|
|
185
185
|
pattern: format_pattern
|
186
186
|
)
|
187
187
|
|
188
|
+
next if Helper::SemanticReleaseHelper.should_exclude_commit(
|
189
|
+
commit_scope: commit[:scope],
|
190
|
+
include_scopes: params[:include_scopes],
|
191
|
+
ignore_scopes: params[:ignore_scopes]
|
192
|
+
)
|
193
|
+
|
188
194
|
commit[:hash] = splitted[2]
|
189
195
|
commit[:short_hash] = splitted[3]
|
190
196
|
commit[:author_name] = splitted[4]
|
@@ -273,6 +279,20 @@ module Fastlane
|
|
273
279
|
type: Boolean,
|
274
280
|
optional: true
|
275
281
|
),
|
282
|
+
FastlaneCore::ConfigItem.new(
|
283
|
+
key: :include_scopes,
|
284
|
+
description: "To only include certain scopes when calculating releases",
|
285
|
+
default_value: [],
|
286
|
+
type: Array,
|
287
|
+
optional: true
|
288
|
+
),
|
289
|
+
FastlaneCore::ConfigItem.new(
|
290
|
+
key: :ignore_scopes,
|
291
|
+
description: "To ignore certain scopes when calculating releases",
|
292
|
+
default_value: [],
|
293
|
+
type: Array,
|
294
|
+
optional: true
|
295
|
+
),
|
276
296
|
FastlaneCore::ConfigItem.new(
|
277
297
|
key: :debug,
|
278
298
|
description: "True if you want to log out a debug info",
|
@@ -20,6 +20,20 @@ module Fastlane
|
|
20
20
|
Actions.sh(command, log: params[:debug]).chomp
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.should_exclude_commit(params)
|
24
|
+
commit_scope = params[:commit_scope]
|
25
|
+
scopes_to_include = params[:include_scopes]
|
26
|
+
scopes_to_ignore = params[:ignore_scopes]
|
27
|
+
|
28
|
+
unless scopes_to_include.empty?
|
29
|
+
return !scopes_to_include.include?(commit_scope)
|
30
|
+
end
|
31
|
+
|
32
|
+
unless commit_scope.nil?
|
33
|
+
return scopes_to_ignore.include?(commit_scope)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
23
37
|
def self.parse_commit(params)
|
24
38
|
commit_subject = params[:commit_subject].strip
|
25
39
|
commit_body = params[:commit_body]
|
@@ -1 +1 @@
|
|
1
|
-
module Fastlane module SemanticRelease VERSION = "1.
|
1
|
+
module Fastlane module SemanticRelease VERSION = "1.18.0" end end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-semantic_release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jiří Otáhal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|