Skip to content

Commit 4d560e1

Browse files
authored
Add next_version parameter to release notes update actions (#706)
2 parents cf82fb7 + 169bb36 commit 4d560e1

5 files changed

Lines changed: 173 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _None_
1414

1515
### Bug Fixes
1616

17-
_None_
17+
- Added optional `next_version` parameter to `android_update_release_notes` and `ios_update_release_notes` actions, allowing callers to provide the next version directly instead of relying on the built-in calculator that assumes minor version caps at 9. This fixes incorrect version bumps (e.g., 8.9 → 9.0 instead of 8.10) for apps using semantic versioning. [#706]
1818

1919
### Internal Changes
2020

lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ def self.run(params)
1010
require_relative '../../helper/release_notes_helper'
1111
require_relative '../../helper/git_helper'
1212

13+
UI.user_error!('You must provide a non-empty value for either `next_version` or `new_version`') if params[:next_version].to_s.strip.empty? && params[:new_version].to_s.strip.empty?
14+
1315
path = params[:release_notes_file_path]
14-
next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_short_version(params[:new_version])
16+
next_version = params[:next_version]&.strip
17+
next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_short_version(params[:new_version]) if next_version.nil? || next_version.empty?
1518

1619
Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
1720
Fastlane::Helper::GitHelper.commit(message: "Release Notes: add new section for next version (#{next_version})", files: path)
@@ -36,6 +39,18 @@ def self.available_options
3639
FastlaneCore::ConfigItem.new(key: :new_version,
3740
env_name: 'FL_ANDROID_UPDATE_RELEASE_NOTES_VERSION',
3841
description: 'The version we are currently freezing; An empty entry for the _next_ version after this one will be added to the release notes',
42+
deprecated: 'Deprecated in favor of `next_version`. ' \
43+
'The `new_version` parameter computes the next version using a built-in calculator ' \
44+
'that assumes the minor version rolls over to the next major at 9, which is incorrect for apps using semantic versioning',
45+
optional: true,
46+
conflicting_options: [:next_version],
47+
type: String),
48+
FastlaneCore::ConfigItem.new(key: :next_version,
49+
description: 'The next version to use as the section title in the release notes. ' \
50+
'This value is used directly as the section title. ' \
51+
'Use this if your app does not follow the default versioning convention (minor capped at 9)',
52+
optional: true,
53+
conflicting_options: [:new_version],
3954
type: String),
4055
FastlaneCore::ConfigItem.new(key: :release_notes_file_path,
4156
env_name: 'FL_ANDROID_UPDATE_RELEASE_NOTES_FILE_PATH',

lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ def self.run(params)
1010
require_relative '../../helper/release_notes_helper'
1111
require_relative '../../helper/git_helper'
1212

13+
UI.user_error!('You must provide a non-empty value for either `next_version` or `new_version`') if params[:next_version].to_s.strip.empty? && params[:new_version].to_s.strip.empty?
14+
1315
path = params[:release_notes_file_path]
14-
next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(params[:new_version])
16+
next_version = params[:next_version]&.strip
17+
next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(params[:new_version]) if next_version.nil? || next_version.empty?
1518

1619
Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
1720
Fastlane::Helper::GitHelper.commit(message: "Release Notes: add new section for next version (#{next_version})", files: path)
@@ -36,6 +39,18 @@ def self.available_options
3639
FastlaneCore::ConfigItem.new(key: :new_version,
3740
env_name: 'FL_IOS_UPDATE_RELEASE_NOTES_VERSION',
3841
description: 'The version we are currently freezing; An empty entry for the _next_ version after this one will be added to the release notes',
42+
deprecated: 'Deprecated in favor of `next_version`. ' \
43+
'The `new_version` parameter computes the next version using a built-in calculator ' \
44+
'that assumes the minor version rolls over to the next major at 9, which is incorrect for apps using semantic versioning',
45+
optional: true,
46+
conflicting_options: [:next_version],
47+
type: String),
48+
FastlaneCore::ConfigItem.new(key: :next_version,
49+
description: 'The next version to use as the section title in the release notes. ' \
50+
'This value is used directly as the section title. ' \
51+
'Use this if your app does not follow the default versioning convention (minor capped at 9)',
52+
optional: true,
53+
conflicting_options: [:new_version],
3954
type: String),
4055
FastlaneCore::ConfigItem.new(key: :release_notes_file_path,
4156
env_name: 'FL_IOS_UPDATE_RELEASE_NOTES_FILE_PATH',

spec/android_update_release_notes_spec.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,75 @@
6161
expect(File.read(changelog_md)).to eq(new_section + content)
6262
end
6363
end
64+
65+
it 'uses next_version directly when provided' do
66+
in_tmp_dir do |tmp_dir|
67+
# Arrange
68+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
69+
File.write(release_notes_txt, content)
70+
71+
expected_section = <<~CONTENT
72+
8.10
73+
-----
74+
75+
76+
CONTENT
77+
78+
# Act
79+
run_described_fastlane_action(
80+
next_version: '8.10'
81+
)
82+
83+
# Assert
84+
expect(File.read(release_notes_txt)).to eq(expected_section + content)
85+
end
86+
end
87+
88+
it 'raises an error when both new_version and next_version are provided' do
89+
in_tmp_dir do |tmp_dir|
90+
# Arrange
91+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
92+
File.write(release_notes_txt, content)
93+
94+
# Act & Assert
95+
expect do
96+
run_described_fastlane_action(
97+
new_version: '8.9',
98+
next_version: '8.10'
99+
)
100+
end.to raise_error(FastlaneCore::Interface::FastlaneError, /Unresolved conflict between options/)
101+
end
102+
end
103+
104+
it 'raises an error when neither new_version nor next_version is provided' do
105+
in_tmp_dir do |tmp_dir|
106+
# Arrange
107+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
108+
File.write(release_notes_txt, content)
109+
110+
# Act & Assert
111+
expect do
112+
run_described_fastlane_action(
113+
release_notes_file_path: release_notes_txt
114+
)
115+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'You must provide a non-empty value for either `next_version` or `new_version`')
116+
end
117+
end
118+
119+
it 'raises an error when next_version is an empty string' do
120+
in_tmp_dir do |tmp_dir|
121+
# Arrange
122+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
123+
File.write(release_notes_txt, content)
124+
125+
# Act & Assert
126+
expect do
127+
run_described_fastlane_action(
128+
next_version: '',
129+
release_notes_file_path: release_notes_txt
130+
)
131+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'You must provide a non-empty value for either `next_version` or `new_version`')
132+
end
133+
end
64134
end
65135
end

spec/ios_update_release_notes_spec.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,75 @@
6161
expect(File.read(changelog_md)).to eq(new_section + content)
6262
end
6363
end
64+
65+
it 'uses next_version directly when provided' do
66+
in_tmp_dir do |tmp_dir|
67+
# Arrange
68+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
69+
File.write(release_notes_txt, content)
70+
71+
expected_section = <<~CONTENT
72+
8.10
73+
-----
74+
75+
76+
CONTENT
77+
78+
# Act
79+
run_described_fastlane_action(
80+
next_version: '8.10'
81+
)
82+
83+
# Assert
84+
expect(File.read(release_notes_txt)).to eq(expected_section + content)
85+
end
86+
end
87+
88+
it 'raises an error when both new_version and next_version are provided' do
89+
in_tmp_dir do |tmp_dir|
90+
# Arrange
91+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
92+
File.write(release_notes_txt, content)
93+
94+
# Act & Assert
95+
expect do
96+
run_described_fastlane_action(
97+
new_version: '8.9',
98+
next_version: '8.10'
99+
)
100+
end.to raise_error(FastlaneCore::Interface::FastlaneError, /Unresolved conflict between options/)
101+
end
102+
end
103+
104+
it 'raises an error when neither new_version nor next_version is provided' do
105+
in_tmp_dir do |tmp_dir|
106+
# Arrange
107+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
108+
File.write(release_notes_txt, content)
109+
110+
# Act & Assert
111+
expect do
112+
run_described_fastlane_action(
113+
release_notes_file_path: release_notes_txt
114+
)
115+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'You must provide a non-empty value for either `next_version` or `new_version`')
116+
end
117+
end
118+
119+
it 'raises an error when next_version is an empty string' do
120+
in_tmp_dir do |tmp_dir|
121+
# Arrange
122+
release_notes_txt = File.join(tmp_dir, 'RELEASE-NOTES.txt')
123+
File.write(release_notes_txt, content)
124+
125+
# Act & Assert
126+
expect do
127+
run_described_fastlane_action(
128+
next_version: '',
129+
release_notes_file_path: release_notes_txt
130+
)
131+
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'You must provide a non-empty value for either `next_version` or `new_version`')
132+
end
133+
end
64134
end
65135
end

0 commit comments

Comments
 (0)