fastlane-plugin-semantic_versioning 2.0.0 → 2.1.1
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_versioning/actions/get_versioning_info_action.rb +19 -10
- data/lib/fastlane/plugin/semantic_versioning/actions/prepare_versioning_action.rb +97 -0
- data/lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb +9 -2
- data/lib/fastlane/plugin/semantic_versioning/helper/semantic_versioning_helper.rb +54 -19
- data/lib/fastlane/plugin/semantic_versioning/version.rb +3 -1
- data/lib/fastlane/plugin/semantic_versioning.rb +3 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d962764d77e655baf9b60aae168bcf8ad44bbaa72f086459a289fec254ccdf7
|
4
|
+
data.tar.gz: 3880d7197a78a347153559ace10fc8ac2d9a70964327c01a698da27928482f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3b6f1b6adec4767c6a713cd73cca76f11e4953fcb65045773f7743abf631241b4c734b5418a0fcd483d2a8f44e88a0bec90c7e57ddbe70e181936b9774dbce
|
7
|
+
data.tar.gz: beef78408a0e60a49d8519304e58a07381afff3239f6ee3b8df65d64669d24f2872793864e34640911dc4d359488cc0bdceddf967552fcfe7f4185c5399b3616
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fastlane/action"
|
2
4
|
require "fastlane_core/configuration/config_item"
|
3
5
|
require_relative "../helper/semantic_versioning_helper"
|
@@ -13,6 +15,7 @@ module Fastlane
|
|
13
15
|
SEMVER_BUMPABLE = :SEMVER_BUMPABLE
|
14
16
|
end
|
15
17
|
|
18
|
+
# Action to retrieve semantic versioning information from commit history.
|
16
19
|
class GetVersioningInfoAction < Action
|
17
20
|
def self.run(params)
|
18
21
|
params[:allowed_types].map!(&:to_sym)
|
@@ -32,8 +35,10 @@ module Fastlane
|
|
32
35
|
)
|
33
36
|
|
34
37
|
bump_type = Helper::SemanticVersioningHelper.bump_type(commits: commits, force_type: params[:force_type])
|
35
|
-
new_version = Helper::SemanticVersioningHelper.increase_version(current_version: current_version,
|
36
|
-
|
38
|
+
new_version = Helper::SemanticVersioningHelper.increase_version(current_version: current_version,
|
39
|
+
bump_type: bump_type)
|
40
|
+
new_changelog = Helper::SemanticVersioningHelper.build_changelog(version: new_version, commits: commits,
|
41
|
+
type_map: params[:type_map])
|
37
42
|
bumpable = current_version != new_version
|
38
43
|
|
39
44
|
Actions.lane_context[SharedValues::SEMVER_CURRENT_VERSION] = current_version
|
@@ -43,9 +48,10 @@ module Fastlane
|
|
43
48
|
Actions.lane_context[SharedValues::SEMVER_NEW_CHANGELOG] = new_changelog
|
44
49
|
Actions.lane_context[SharedValues::SEMVER_BUMPABLE] = bumpable
|
45
50
|
|
46
|
-
|
51
|
+
bumpable
|
47
52
|
end
|
48
53
|
|
54
|
+
# :nocov:
|
49
55
|
def self.description
|
50
56
|
"Retrieve semantic versioning information from commit history."
|
51
57
|
end
|
@@ -75,6 +81,7 @@ module Fastlane
|
|
75
81
|
# Optional:
|
76
82
|
"Reads commits from last version and determines next version and changelog."
|
77
83
|
end
|
84
|
+
# :nocov:
|
78
85
|
|
79
86
|
def self.available_options
|
80
87
|
[
|
@@ -82,7 +89,8 @@ module Fastlane
|
|
82
89
|
env_name: "SEMANTIC_VERSIONING_ALLOWED_TYPES",
|
83
90
|
description: "List of allowed commit types",
|
84
91
|
optional: true,
|
85
|
-
default_value: %w[build ci docs feat fix perf refactor style test chore revert
|
92
|
+
default_value: %w[build ci docs feat fix perf refactor style test chore revert
|
93
|
+
bump init],
|
86
94
|
type: Array),
|
87
95
|
FastlaneCore::ConfigItem.new(key: :bump_map,
|
88
96
|
description: "Map of commit types to their bump level (major, minor, patch)",
|
@@ -107,29 +115,30 @@ module Fastlane
|
|
107
115
|
description: "Map of types to section titles for the changelog." \
|
108
116
|
"Only the specified types will be used for the changelog",
|
109
117
|
optional: true,
|
110
|
-
default_value: { breaking: "BREAKING CHANGES", feat: "Features",
|
118
|
+
default_value: { breaking: "BREAKING CHANGES", feat: "Features",
|
119
|
+
fix: "Bug Fixes" },
|
111
120
|
is_string: false,
|
112
121
|
verify_block: ->(value) { verify_type_map(value) })
|
113
122
|
]
|
114
123
|
end
|
115
124
|
|
116
125
|
def self.verify_type_map(value)
|
117
|
-
UI.user_error!("Parameter 'type_map' must be a Hash.") unless value.
|
118
|
-
# It could be helpful to also test for valid keys, which must all be part of ConfigItem :allowed_types plus breaking.
|
119
|
-
# How to check this?
|
126
|
+
UI.user_error!("Parameter 'type_map' must be a Hash.") unless value.is_a?(Hash)
|
120
127
|
end
|
121
128
|
|
122
129
|
def self.verify_bump_map(value)
|
123
|
-
UI.user_error!("Parameter 'bump_map' must be a Hash.") unless value.
|
130
|
+
UI.user_error!("Parameter 'bump_map' must be a Hash.") unless value.is_a?(Hash)
|
124
131
|
end
|
125
132
|
|
126
|
-
|
133
|
+
# :nocov:
|
134
|
+
def self.is_supported?(_platform)
|
127
135
|
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
128
136
|
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
129
137
|
#
|
130
138
|
# [:ios, :mac, :android].include?(platform)
|
131
139
|
true
|
132
140
|
end
|
141
|
+
# :nocov:
|
133
142
|
end
|
134
143
|
end
|
135
144
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fastlane/action"
|
4
|
+
require_relative "../helper/semantic_versioning_helper"
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Actions
|
8
|
+
# Action to prepare the Xcode project for automatic versioning
|
9
|
+
class PrepareVersioningAction < Action
|
10
|
+
def self.run(params)
|
11
|
+
xcodeproj_path = params[:xcodeproj] || Dir.glob("*.xcodeproj").first
|
12
|
+
|
13
|
+
Fastlane::UI.user_error!("Unable to determine *.xcodeproj and no :xcodeproj specified") if xcodeproj_path.nil?
|
14
|
+
|
15
|
+
project = Helper::SemanticVersioningHelper.project(xcodeproj_path)
|
16
|
+
target = Helper::SemanticVersioningHelper.main_target
|
17
|
+
main_group = Helper::SemanticVersioningHelper.main_group
|
18
|
+
|
19
|
+
info_plist_file = File.join(main_group.path, "Info.plist")
|
20
|
+
info_plist_path = File.join(project.path.dirname, info_plist_file)
|
21
|
+
|
22
|
+
current_version = Fastlane::Actions::GetVersionNumberAction.run(xcodeproj: xcodeproj_path)
|
23
|
+
Helper::SemanticVersioningHelper.ensure_info_plist(info_plist_path)
|
24
|
+
%w[CFBundleVersion CFBundleShortVersionString].each do |key|
|
25
|
+
unless Fastlane::Actions::GetInfoPlistValueAction.run(path: info_plist_path, key: key)
|
26
|
+
Fastlane::Actions::SetInfoPlistValueAction.run(path: info_plist_path, key: key, value: current_version)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
target.build_configurations.each do |config|
|
31
|
+
config.build_settings["VERSIONING_SYSTEM"] = "apple-generic"
|
32
|
+
config.build_settings.delete("MARKETING_VERSION")
|
33
|
+
config.build_settings.delete("GENERATE_INFOPLIST_FILE")
|
34
|
+
end
|
35
|
+
|
36
|
+
project.save
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
# :nocov:
|
41
|
+
def self.description
|
42
|
+
"Prepares the Xcodeproject to be used with automatic versioning by tools."
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.authors
|
46
|
+
["kassi"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.output
|
50
|
+
# Define the shared values you are going to provide
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.return_value
|
54
|
+
# If your method provides a return value, you can describe here what it does
|
55
|
+
"Truthy value when everything worked out well."
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.details
|
59
|
+
# Optional:
|
60
|
+
"Changes the versioning style and makes sure that version information is extracted into Info.plist " \
|
61
|
+
"to be used with agvtool"
|
62
|
+
end
|
63
|
+
# :nocov:
|
64
|
+
|
65
|
+
def self.available_options
|
66
|
+
[
|
67
|
+
FastlaneCore::ConfigItem.new(key: :main_group,
|
68
|
+
env_name: "SEMANTIC_VERSIONING_MAIN_GROUP",
|
69
|
+
description: "The name of the main group of the xcode project",
|
70
|
+
optional: true,
|
71
|
+
default_value: nil,
|
72
|
+
type: String),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
74
|
+
env_name: "SEMANTIC_VERSIONING_PROJECT",
|
75
|
+
description: "The path to your project file (Not the workspace). Optional if you have only one",
|
76
|
+
optional: true,
|
77
|
+
default_value: nil,
|
78
|
+
verify_block: proc do |value|
|
79
|
+
if value.end_with?(".xcworkspace")
|
80
|
+
UI.user_error!("Please pass the path to the project, not the workspace")
|
81
|
+
end
|
82
|
+
UI.user_error!("Could not find Xcode project") unless File.exist?(value)
|
83
|
+
end)
|
84
|
+
]
|
85
|
+
end
|
86
|
+
|
87
|
+
# :nocov:
|
88
|
+
def self.is_supported?(platform)
|
89
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
90
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
91
|
+
#
|
92
|
+
%i[ios mac].include?(platform)
|
93
|
+
end
|
94
|
+
# :nocov:
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fastlane/action"
|
2
4
|
require_relative "../helper/semantic_versioning_helper"
|
3
5
|
|
4
6
|
module Fastlane
|
5
7
|
module Actions
|
8
|
+
# Action to bumps the version according to semantic versioning and writes a changelog.
|
6
9
|
class SemanticBumpAction < Action
|
7
10
|
def self.run(params)
|
8
11
|
unless Actions.lane_context.key?(SharedValues::SEMVER_BUMPABLE)
|
@@ -32,9 +35,10 @@ module Fastlane
|
|
32
35
|
include: [params[:changelog_file]].compact
|
33
36
|
)
|
34
37
|
|
35
|
-
|
38
|
+
true
|
36
39
|
end
|
37
40
|
|
41
|
+
# :nocov:
|
38
42
|
def self.description
|
39
43
|
"Bumps the version according to semantic versioning and writes a changelog."
|
40
44
|
end
|
@@ -56,6 +60,7 @@ module Fastlane
|
|
56
60
|
# Optional:
|
57
61
|
"Reads commits from last version and determines next version and changelog."
|
58
62
|
end
|
63
|
+
# :nocov:
|
59
64
|
|
60
65
|
def self.available_options
|
61
66
|
[
|
@@ -74,13 +79,15 @@ module Fastlane
|
|
74
79
|
]
|
75
80
|
end
|
76
81
|
|
77
|
-
|
82
|
+
# :nocov:
|
83
|
+
def self.is_supported?(_platform)
|
78
84
|
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
79
85
|
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
80
86
|
#
|
81
87
|
# [:ios, :mac, :android].include?(platform)
|
82
88
|
true
|
83
89
|
end
|
90
|
+
# :nocov:
|
84
91
|
end
|
85
92
|
end
|
86
93
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fastlane_core/ui/ui"
|
2
4
|
require "fastlane/actions/get_version_number"
|
3
5
|
require "git"
|
6
|
+
require "xcodeproj"
|
4
7
|
|
5
8
|
module Fastlane
|
6
9
|
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
@@ -22,16 +25,12 @@ module Fastlane
|
|
22
25
|
format.sub("$version", tag)
|
23
26
|
end
|
24
27
|
|
25
|
-
def self.git_tag_exists?(tag)
|
26
|
-
git.tags.include?(tag)
|
27
|
-
end
|
28
|
-
|
29
28
|
# Retrieves git commits and returns them grouped by type
|
30
29
|
def self.git_commits(from:, allowed_types:, bump_map:)
|
31
30
|
logs = from ? git.log(-1).between(from) : git.log(-1)
|
32
|
-
logs.reverse_each.
|
31
|
+
logs.reverse_each.filter_map { |commit|
|
33
32
|
parse_conventional_commit(commit: commit, allowed_types: allowed_types, bump_map: bump_map)
|
34
|
-
|
33
|
+
}
|
35
34
|
end
|
36
35
|
|
37
36
|
def self.parse_conventional_commit(commit:, allowed_types:, bump_map:)
|
@@ -39,7 +38,7 @@ module Fastlane
|
|
39
38
|
commit.message.match(/^(?<type>#{types})(\((?<scope>\S+)\))?(?<major>!)?:\s+(?<subject>[^\n\r]+)(\z|\n\n(?<body>.*\z))/m) do |match|
|
40
39
|
cc = {
|
41
40
|
type: match[:type].to_sym,
|
42
|
-
major:
|
41
|
+
major: !match[:major].nil?,
|
43
42
|
scope: match[:scope],
|
44
43
|
subject: match[:subject],
|
45
44
|
body: match[:body],
|
@@ -62,7 +61,7 @@ module Fastlane
|
|
62
61
|
|
63
62
|
return bump_map[:breaking] if commit[:breaking]
|
64
63
|
|
65
|
-
|
64
|
+
bump_map[commit[:type]]
|
66
65
|
end
|
67
66
|
|
68
67
|
def self.bump_type(commits:, force_type: nil)
|
@@ -83,7 +82,7 @@ module Fastlane
|
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
|
-
|
85
|
+
result
|
87
86
|
end
|
88
87
|
|
89
88
|
def self.group_commits(commits:, allowed_types:)
|
@@ -91,9 +90,7 @@ module Fastlane
|
|
91
90
|
result[:none] = []
|
92
91
|
|
93
92
|
commits.each do |commit|
|
94
|
-
if commit[:breaking] && allowed_types.include?(:breaking)
|
95
|
-
result[:breaking] << commit
|
96
|
-
end
|
93
|
+
result[:breaking] << commit if commit[:breaking] && allowed_types.include?(:breaking)
|
97
94
|
|
98
95
|
if commit[:major] && !allowed_types.include?(commit[:type])
|
99
96
|
result[:none] << commit
|
@@ -105,7 +102,7 @@ module Fastlane
|
|
105
102
|
result[commit[:type]] << commit
|
106
103
|
end
|
107
104
|
|
108
|
-
|
105
|
+
result
|
109
106
|
end
|
110
107
|
|
111
108
|
def self.increase_version(current_version:, bump_type:)
|
@@ -122,7 +119,7 @@ module Fastlane
|
|
122
119
|
version_array[2] += 1
|
123
120
|
end
|
124
121
|
|
125
|
-
|
122
|
+
version_array.join(".")
|
126
123
|
end
|
127
124
|
|
128
125
|
# Builds and returns th changelog for the upcoming release.
|
@@ -147,7 +144,7 @@ module Fastlane
|
|
147
144
|
lines << ""
|
148
145
|
end
|
149
146
|
|
150
|
-
|
147
|
+
"#{lines.join("\n")}\n"
|
151
148
|
end
|
152
149
|
|
153
150
|
def self.write_changelog(path:, changelog:)
|
@@ -168,15 +165,53 @@ module Fastlane
|
|
168
165
|
.sub("$new_version", Actions.lane_context[Actions::SharedValues::SEMVER_NEW_VERSION]))
|
169
166
|
end
|
170
167
|
|
171
|
-
def self.git_command(args)
|
172
|
-
Actions.sh("git #{args.join(' ')}").chomp
|
173
|
-
end
|
174
|
-
|
175
168
|
def self.git
|
176
169
|
# rubocop:disable Style/ClassVars
|
177
170
|
@@git ||= Git.open(".")
|
178
171
|
# rubocop:enable Style/ClassVars
|
179
172
|
end
|
173
|
+
|
174
|
+
def self.git_tag_exists?(tag)
|
175
|
+
git.tags.include?(tag)
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.project(path = nil)
|
179
|
+
# rubocop:disable Style/ClassVars
|
180
|
+
@@project ||= Xcodeproj::Project.open(path)
|
181
|
+
# rubocop:enable Style/ClassVars
|
182
|
+
end
|
183
|
+
|
184
|
+
def self.main_target
|
185
|
+
project.targets.first
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.current_version
|
189
|
+
@current_version ||= main_target.build_configurations.first.build_settings["MARKETING_VERSION"] || "1.0"
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.main_group(name = nil)
|
193
|
+
project.main_group[name || main_target.name]
|
194
|
+
end
|
195
|
+
|
196
|
+
def self.ensure_info_plist(path)
|
197
|
+
return if File.exist?(path)
|
198
|
+
|
199
|
+
File.write(path, <<-PLIST)
|
200
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
201
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
202
|
+
<plist version="1.0">
|
203
|
+
<dict>
|
204
|
+
</dict>
|
205
|
+
</plist>
|
206
|
+
PLIST
|
207
|
+
|
208
|
+
info_plist = main_group.new_file("Info.plist")
|
209
|
+
info_plist.include_in_index = nil
|
210
|
+
info_plist.set_last_known_file_type("text.plist")
|
211
|
+
main_target.build_configurations.each do |config|
|
212
|
+
config.build_settings["INFOPLIST_FILE"] = info_plist.full_path.to_s
|
213
|
+
end
|
214
|
+
end
|
180
215
|
end
|
181
216
|
end
|
182
217
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fastlane/plugin/semantic_versioning/version"
|
2
4
|
|
3
5
|
module Fastlane
|
6
|
+
# Provides actions for dealing with semantic versions and conventional commits
|
4
7
|
module SemanticVersioning
|
5
8
|
# Return all .rb files inside the "actions" and "helper" directory
|
6
9
|
def self.all_classes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-semantic_versioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karsten Silkenbäumer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xcodeproj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.24'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.24'
|
27
41
|
description:
|
28
42
|
email: 993392+kassi@users.noreply.github.com
|
29
43
|
executables: []
|
@@ -34,6 +48,7 @@ files:
|
|
34
48
|
- README.md
|
35
49
|
- lib/fastlane/plugin/semantic_versioning.rb
|
36
50
|
- lib/fastlane/plugin/semantic_versioning/actions/get_versioning_info_action.rb
|
51
|
+
- lib/fastlane/plugin/semantic_versioning/actions/prepare_versioning_action.rb
|
37
52
|
- lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb
|
38
53
|
- lib/fastlane/plugin/semantic_versioning/helper/semantic_versioning_helper.rb
|
39
54
|
- lib/fastlane/plugin/semantic_versioning/version.rb
|