fastlane-plugin-semantic_versioning 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1205dbf528eadda53b7561ee36d93418c9f12fd7e5b8baa1f93f3f338411baa8
4
- data.tar.gz: e083a5c015ecd318254c853589dc9233aa3e86b3da96699ebeaeecf95c2630f7
3
+ metadata.gz: c974c8e59adc155a1442566a6198e81d8192a85c2f0822cf20acccf8d3c6a320
4
+ data.tar.gz: 61060c47ebc660fdec7999392e05b7ee7303212b14cee2f414058579d7ee0840
5
5
  SHA512:
6
- metadata.gz: 03b8bd862f3f5ef41791fd214864ac6d15c3928fe6e1fbf27acdb817619c6d3acae71b98c66b342a34d978795172e429fa7b0849e22313273fdbeac27a2fc4b5
7
- data.tar.gz: c5efd5ec4a7f1e73150f105d6f82a0c54aa52926d694224286ce64fb38f5614abb916b25fb2c2933ad099bc843bad6e01f5ead837a9cacf980a3a321c811e6c9
6
+ metadata.gz: bca9ec5b145f927fab9a16bf6483b988133a30c7e4032ff756d3acbc24dffb3eae18b86ff02d1dcaa17293fd4077eab28a5f23ee3734401303fb1092dd2027e1
7
+ data.tar.gz: 4f04bc1f080a83b49d548a4e011692d0482c60dbc95e3601781f0239e672924ee1495ee4ebf114461dbef5cdbf627bbf1f24e75fc0fb70eb0b91816742080584
@@ -13,6 +13,7 @@ module Fastlane
13
13
  SEMVER_NEW_VERSION = :SEMVER_NEW_VERSION
14
14
  SEMVER_NEW_CHANGELOG = :SEMVER_NEW_CHANGELOG
15
15
  SEMVER_BUMPABLE = :SEMVER_BUMPABLE
16
+ SEMVER_VERSIONING_SYSTEM = :SEMVER_VERSIONING_SYSTEM
16
17
  end
17
18
 
18
19
  # Action to retrieve semantic versioning information from commit history.
@@ -23,9 +24,13 @@ module Fastlane
23
24
  params[:bump_map].transform_values!(&:to_sym)
24
25
  params[:force_type] = params[:force_type]&.to_sym
25
26
 
26
- UI.message("The semantic_versioning plugin is working!")
27
+ verify_type_map(params[:type_map])
28
+ verify_bump_map(params[:bump_map])
29
+ Helper::SemanticVersioningHelper.verify_versioning_system(params[:versioning_system])
27
30
 
28
- current_version = Helper::SemanticVersioningHelper.version_number
31
+ system = lane_context[SharedValues::SEMVER_VERSIONING_SYSTEM] = params[:versioning_system]
32
+
33
+ current_version = Helper::SemanticVersioningHelper.version_number(system: system)
29
34
  formatted_tag = Helper::SemanticVersioningHelper.formatted_tag(current_version, params[:tag_format])
30
35
 
31
36
  commits = Helper::SemanticVersioningHelper.git_commits(
@@ -68,7 +73,8 @@ module Fastlane
68
73
  ["SEMVER_BUMP_TYPE", "Type of version bump. One of major, minor, or patch"],
69
74
  ["SEMVER_NEW_VERSION", "New version that would have to be set from current version and commits"],
70
75
  ["SEMVER_NEW_CHANGELOG", "New changelog section for the new bump"],
71
- ["SEMVER_BUMPABLE", "True if a version bump is possible"]
76
+ ["SEMVER_BUMPABLE", "True if a version bump is possible"],
77
+ ["SEMVER_VERSIONING_SYSTEM", "The versioning system used"]
72
78
  ]
73
79
  end
74
80
 
@@ -118,7 +124,16 @@ module Fastlane
118
124
  default_value: { breaking: "BREAKING CHANGES", feat: "Features",
119
125
  fix: "Bug Fixes" },
120
126
  is_string: false,
121
- verify_block: ->(value) { verify_type_map(value) })
127
+ verify_block: ->(value) { verify_type_map(value) }),
128
+ FastlaneCore::ConfigItem.new(key: :versioning_system,
129
+ env_name: "SEMANTIC_VERSIONING_VERSIONING_SYSTEM",
130
+ description: "Type of versioning to use. Can be 'manual' or 'apple-generic'." \
131
+ "For 'apple-generic', the project has to be prepared with prepare_versioning." \
132
+ "Defaults to 'manual'",
133
+ optional: true,
134
+ default_value: "manual",
135
+ is_string: true,
136
+ verify_block: ->(value) { Helper::SemanticVersioningHelper.verify_versioning_system(value) })
122
137
  ]
123
138
  end
124
139
 
@@ -135,8 +150,7 @@ module Fastlane
135
150
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
136
151
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
137
152
  #
138
- # [:ios, :mac, :android].include?(platform)
139
- true
153
+ %i[ios mac].include?(platform)
140
154
  end
141
155
  # :nocov:
142
156
  end
@@ -19,15 +19,20 @@ module Fastlane
19
19
  info_plist_file = File.join(main_group.path, "Info.plist")
20
20
  info_plist_path = File.join(project.path.dirname, info_plist_file)
21
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
+
22
30
  target.build_configurations.each do |config|
23
31
  config.build_settings["VERSIONING_SYSTEM"] = "apple-generic"
24
32
  config.build_settings.delete("MARKETING_VERSION")
25
33
  config.build_settings.delete("GENERATE_INFOPLIST_FILE")
26
-
27
- config.build_settings["INFOPLIST_FILE"] = info_plist_file unless config.build_settings["INFOPLIST_FILE"]
28
-
29
- Helper::SemanticVersioningHelper.ensure_info_plist(info_plist_path)
30
34
  end
35
+
31
36
  project.save
32
37
  true
33
38
  end
@@ -8,19 +8,22 @@ module Fastlane
8
8
  # Action to bumps the version according to semantic versioning and writes a changelog.
9
9
  class SemanticBumpAction < Action
10
10
  def self.run(params)
11
- unless Actions.lane_context.key?(SharedValues::SEMVER_BUMPABLE)
11
+ unless Actions.lane_context.key?(SharedValues::SEMVER_BUMPABLE) && Actions.lane_context.key?(SharedValues::SEMVER_VERSIONING_SYSTEM)
12
12
  UI.user_error!("No semver information found. Please run get_versioning_info beforehand.")
13
13
  end
14
14
 
15
+ Helper::SemanticVersioningHelper.verify_versioning_system(Actions.lane_context[SharedValues::SEMVER_VERSIONING_SYSTEM])
16
+
15
17
  unless Actions.lane_context[SharedValues::SEMVER_BUMPABLE]
16
18
  UI.message("No version bump detected.")
17
19
  return false
18
20
  end
19
21
 
22
+ system = Actions.lane_context[SharedValues::SEMVER_VERSIONING_SYSTEM]
20
23
  version_number = Actions.lane_context[SharedValues::SEMVER_NEW_VERSION]
21
24
  next_changelog = Actions.lane_context[SharedValues::SEMVER_NEW_CHANGELOG]
22
25
 
23
- Fastlane::Actions::IncrementVersionNumberAction.run(version_number: version_number)
26
+ Helper::SemanticVersioningHelper.set_version_number(version_number: version_number, system: system)
24
27
 
25
28
  if params[:changelog_file]
26
29
  Helper::SemanticVersioningHelper.write_changelog(
@@ -75,7 +78,16 @@ module Fastlane
75
78
  description: "Filename for the changelog",
76
79
  optional: true,
77
80
  default_value: "CHANGELOG.md",
78
- type: String)
81
+ type: String),
82
+ FastlaneCore::ConfigItem.new(key: :versioning_system,
83
+ env_name: "SEMANTIC_VERSIONING_VERSIONING_SYSTEM",
84
+ description: "Type of versioning to use. Can be 'manual' or 'apple-generic'." \
85
+ "For 'apple-generic', the project has to be prepared with prepare_versioning." \
86
+ "Defaults to 'manual'",
87
+ optional: true,
88
+ default_value: "manual",
89
+ is_string: true,
90
+ verify_block: ->(value) { Helper::SemanticVersioningHelper.verify_versioning_system(value) })
79
91
  ]
80
92
  end
81
93
 
@@ -84,8 +96,7 @@ module Fastlane
84
96
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
85
97
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
86
98
  #
87
- # [:ios, :mac, :android].include?(platform)
88
- true
99
+ %i[ios mac].include?(platform)
89
100
  end
90
101
  # :nocov:
91
102
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "fastlane_core/ui/ui"
4
4
  require "fastlane/actions/get_version_number"
5
+ require "fastlane/plugin/versioning"
5
6
  require "git"
6
7
  require "xcodeproj"
7
8
 
@@ -13,12 +14,27 @@ module Fastlane
13
14
  # class methods that you define here become available in your action
14
15
  # as `Helper::SemanticVersioningHelper.your_method`
15
16
  #
16
- def self.show_message
17
- UI.message("Hello from the semantic_versioning plugin helper!")
17
+ def self.version_number(system:)
18
+ if system == "apple-generic"
19
+ Actions::GetVersionNumberAction.run({})
20
+ else
21
+ Actions::GetVersionNumberFromXcodeprojAction.run({})
22
+ end
23
+ end
24
+
25
+ def self.set_version_number(version_number:, system:)
26
+ if system == "apple-generic"
27
+ Fastlane::Actions::IncrementVersionNumberAction.run(version_number: version_number)
28
+ else
29
+ Actions::IncrementVersionNumberInXcodeprojAction.run(version_number: version_number)
30
+ end
18
31
  end
19
32
 
20
- def self.version_number
21
- Actions::GetVersionNumberAction.run({})
33
+ def self.verify_versioning_system(value)
34
+ allowed = %w[apple-generic manual]
35
+ return if allowed.include?(value)
36
+
37
+ UI.user_error!("'versioning_system' must be one of #{allowed}")
22
38
  end
23
39
 
24
40
  def self.formatted_tag(tag, format)
@@ -185,10 +201,6 @@ module Fastlane
185
201
  project.targets.first
186
202
  end
187
203
 
188
- def self.current_version
189
- @current_version ||= main_target.build_configurations.first.build_settings["MARKETING_VERSION"] || "1.0"
190
- end
191
-
192
204
  def self.main_group(name = nil)
193
205
  project.main_group[name || main_target.name]
194
206
  end
@@ -196,22 +208,21 @@ module Fastlane
196
208
  def self.ensure_info_plist(path)
197
209
  return if File.exist?(path)
198
210
 
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
- <key>CFBundleVersion</key>
205
- <string>#{current_version}</string>
206
- <key>CFBundleShortVersionString</key>
207
- <string>#{current_version}</string>
208
- </dict>
209
- </plist>
211
+ File.write(path, <<-PLIST)
212
+ <?xml version="1.0" encoding="UTF-8"?>
213
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
214
+ <plist version="1.0">
215
+ <dict>
216
+ </dict>
217
+ </plist>
210
218
  PLIST
211
219
 
212
220
  info_plist = main_group.new_file("Info.plist")
213
- main_target.add_file_references([info_plist])
214
- Fastlane::UI.success("Successfully created the file '#{path}' for agvtool")
221
+ info_plist.include_in_index = nil
222
+ info_plist.set_last_known_file_type("text.plist")
223
+ main_target.build_configurations.each do |config|
224
+ config.build_settings["INFOPLIST_FILE"] = info_plist.full_path.to_s
225
+ end
215
226
  end
216
227
  end
217
228
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module SemanticVersioning
5
- VERSION = "2.1.0"
5
+ VERSION = "3.0.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-semantic_versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
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-20 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fastlane-plugin-versioning
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: git
15
29
  requirement: !ruby/object:Gem::Requirement