forked from aws/aws-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangelog.rake
36 lines (34 loc) · 1.25 KB
/
changelog.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
task 'changelog:version' do
# replaces "Next Release (TBD)" in the CHANGELOG with a version and date
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read }
changelog = changelog.lines.to_a
changelog[0] = "#{$VERSION} (#{Time.now.strftime('%Y-%m-%d')})\n"
changelog = changelog.join
File.open('CHANGELOG.md', 'w', encoding: 'UTF-8') { |f| f.write(changelog) }
sh("git add CHANGELOG.md")
end
task 'changelog:next_release' do
# inserts a "Next Release (TDB)" section at the top of the CHANGELOG
lines = []
lines << "Unreleased Changes\n"
lines << "------------------\n"
lines << "\n"
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read }
changelog = lines.join + changelog
File.open('CHANGELOG.md', 'w', encoding: 'UTF-8') { |f| f.write(changelog) }
sh("git add CHANGELOG.md")
sh("git commit -m 'Added next release section to the changelog. [ci skip]'")
end
task 'changelog:latest' do
# Returns the contents of the most recent CHANGELOG section
changelog = File.open('CHANGELOG.md', 'r', encoding: 'UTF-8') { |f| f.read }
lines = []
changelog.lines.to_a[3..-1].each do |line|
if line.match(/^\d+\.\d+\.\d+/)
break
else
lines << line
end
end
puts lines[0..-2].join
end