Skip to content

Commit 5d88012

Browse files
committed
Adds a optional release_notes_file_path arg to android_update_release_notes
1 parent 0155527 commit 5d88012

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_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::Android::VersionHelper.calc_next_release_short_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_ANDROID_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_ANDROID_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/android_update_release_notes_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
describe Fastlane::Actions::AndroidUpdateReleaseNotesAction 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 '#android_update_release_notes' do
@@ -22,5 +23,20 @@
2223
# Assert
2324
expect(File.read(release_notes_txt)).to eq("1.1\n-----\n\n\n")
2425
end
26+
27+
it 'adds a new section on the given file' do
28+
# Arrange
29+
ENV['PROJECT_ROOT_FOLDER'] = File.dirname(__FILE__)
30+
File.write(changelog_md, '')
31+
32+
# Act
33+
run_described_fastlane_action(
34+
new_version: '1.0',
35+
release_notes_file_path: changelog_md
36+
)
37+
38+
# Assert
39+
expect(File.read(changelog_md)).to eq("1.1\n-----\n\n\n")
40+
end
2541
end
2642
end

0 commit comments

Comments
 (0)