Skip to content

Commit 0155527

Browse files
committed
Updates ios_update_release_notes to accepts an argument with the changelog file path
1 parent fa93f40 commit 0155527

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def self.run(params)
88
require_relative '../../helper/release_notes_helper'
99
require_relative '../../helper/git_helper'
1010

11-
path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'RELEASE-NOTES.txt')
11+
path = params[:release_notes_file_path]
1212
next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(params[:new_version])
1313

1414
Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
@@ -35,6 +35,11 @@ def self.available_options
3535
env_name: 'FL_IOS_UPDATE_RELEASE_NOTES_VERSION',
3636
description: 'The version we are currently freezing; An empty entry for the _next_ version after this one will be added to the release notes',
3737
is_string: true),
38+
FastlaneCore::ConfigItem.new(key: :release_notes_file_path,
39+
env_name: 'FL_IOS_UPDATE_RELEASE_NOTES_FILE_PATH',
40+
description: 'The path to the release notes file to be updated',
41+
is_string: true,
42+
default_value: File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'RELEASE-NOTES.txt')),
3843
]
3944
end
4045

spec/ios_update_release_notes_spec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
describe Fastlane::Actions::IosUpdateReleaseNotesAction do
44
let(:release_notes_txt) { File.join(File.dirname(__FILE__), 'RELEASE-NOTES.txt') }
5+
let(:changelog_md) { File.join(File.dirname(__FILE__), 'CHANGELOG.md') }
56

67
after do
7-
FileUtils.remove_entry release_notes_txt
8+
FileUtils.rm([release_notes_txt, changelog_md], force: true)
89
end
910

1011
describe '#ios_update_release_notes' do
1112
it 'adds a new section on RELEASE-NOTES.txt' do
1213
# Arrange
13-
1414
ENV['PROJECT_ROOT_FOLDER'] = File.dirname(__FILE__)
1515
File.write(release_notes_txt, '')
1616

@@ -22,5 +22,20 @@
2222
# Assert
2323
expect(File.read(release_notes_txt)).to eq("1.1\n-----\n\n\n")
2424
end
25+
26+
it 'adds a new section on the given file' do
27+
# Arrange
28+
ENV['PROJECT_ROOT_FOLDER'] = File.dirname(__FILE__)
29+
File.write(changelog_md, '')
30+
31+
# Act
32+
run_described_fastlane_action(
33+
new_version: '1.0',
34+
release_notes_file_path: changelog_md
35+
)
36+
37+
# Assert
38+
expect(File.read(changelog_md)).to eq("1.1\n-----\n\n\n")
39+
end
2540
end
2641
end

0 commit comments

Comments
 (0)