Skip to content

Commit 973c321

Browse files
committed
Support multiple versions in release announcement.
So releasing 5.1 and 5.0 together won't require manual copy and paste.
1 parent 1e7acf8 commit 973c321

File tree

2 files changed

+67
-51
lines changed

2 files changed

+67
-51
lines changed

tasks/release.rb

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -200,69 +200,47 @@
200200
task release: %w(prep_release tag push)
201201
end
202202

203-
task :announce do
204-
Dir.chdir("pkg/") do
205-
if gem_version.segments[2] == 0 || gem_version.segments[3].is_a?(Integer)
206-
# Not major releases, and not security releases
207-
raise "Only valid for patch releases"
203+
module Announcement
204+
class Version
205+
def initialize(version)
206+
@version, @gem_version = version, Gem::Version.new(version)
208207
end
209208

210-
sums = "$ shasum -a 256 *-#{version}.gem\n" + `shasum -a 256 *-#{version}.gem`
209+
def to_s
210+
@version
211+
end
211212

212-
puts "Hi everyone,"
213-
puts
213+
def previous
214+
@gem_version.segments[0, 3].tap { |v| v[2] -= 1 }.join(".")
215+
end
214216

215-
puts "I am happy to announce that Rails #{version} has been released."
216-
puts
217+
def major_or_security?
218+
@gem_version.segments[2].zero? || @gem_version.segments[3].is_a?(Integer)
219+
end
220+
221+
def rc?
222+
@version =~ /rc/
223+
end
224+
end
225+
end
226+
227+
task :announce do
228+
Dir.chdir("pkg/") do
229+
versions = ENV["VERSIONS"] ? ENV["VERSIONS"].split(",") : [ version ]
230+
versions = versions.sort.map { |v| Announcement::Version.new(v) }
217231

218-
previous_version = gem_version.segments[0, 3]
219-
previous_version[2] -= 1
220-
previous_version = previous_version.join(".")
232+
raise "Only valid for patch releases" if versions.any?(&:major_or_security?)
221233

222-
if version =~ /rc/
234+
if versions.any?(&:rc?)
223235
require "date"
224236
future_date = Date.today + 5
225237
future_date += 1 while future_date.saturday? || future_date.sunday?
226238

227239
github_user = `git config github.user`.chomp
228-
229-
puts <<MSG
230-
If no regressions are found, expect the final release on #{future_date.strftime('%A, %B %-d, %Y')}.
231-
If you find one, please open an [issue on GitHub](https://github.com/rails/rails/issues/new)
232-
#{"and mention me (@#{github_user}) on it, " unless github_user.empty?}so that we can fix it before the final release.
233-
234-
MSG
235240
end
236241

237-
puts <<MSG
238-
## CHANGES since #{previous_version}
239-
240-
To view the changes for each gem, please read the changelogs on GitHub:
241-
242-
MSG
243-
FRAMEWORKS.sort.each do |framework|
244-
puts "* [#{FRAMEWORK_NAMES[framework]} CHANGELOG](https://github.com/rails/rails/blob/v#{version}/#{framework}/CHANGELOG.md)"
245-
end
246-
puts <<MSG
247-
248-
*Full listing*
249-
250-
To see the full list of changes, [check out all the commits on
251-
GitHub](https://github.com/rails/rails/compare/v#{previous_version}...v#{version}).
252-
253-
## SHA-256
254-
255-
If you'd like to verify that your gem is the same as the one I've uploaded,
256-
please use these SHA-256 hashes.
257-
258-
Here are the checksums for #{version}:
259-
260-
```
261-
#{sums}
262-
```
263-
264-
As always, huge thanks to the many contributors who helped with this release.
265-
266-
MSG
242+
require "erb"
243+
template = File.read("../tasks/release_announcement_draft.erb")
244+
puts ERB.new(template, nil, "<>").result(binding)
267245
end
268246
end

tasks/release_announcement_draft.erb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Hi everyone,
2+
3+
I am happy to announce that Rails <%= versions.join(" and ") %> <%= versions.size > 1 ? "have" : "has" %> been released.
4+
5+
<% if future_date %>
6+
If no regressions are found, expect the final release on <%= future_date.strftime("%A, %B %-d, %Y") %>.
7+
If you find one, please open an [issue on GitHub](https://github.com/rails/rails/issues/new)
8+
<%= "and mention me (@github_user}) on it, " unless github_user.empty? %>so that we can fix it before the final release.
9+
<% end %>
10+
<% versions.each do |version| %>
11+
12+
## CHANGES since <%= version.previous %>
13+
14+
To view the changes for each gem, please read the changelogs on GitHub:
15+
<% FRAMEWORKS.sort.each do |framework| %>
16+
<%= "* [#{FRAMEWORK_NAMES[framework]} CHANGELOG](https://github.com/rails/rails/blob/v#{version}/#{framework}/CHANGELOG.md)" %>
17+
<% end %>
18+
19+
*Full listing*
20+
21+
To see the full list of changes, [check out all the commits on
22+
GitHub](https://github.com/rails/rails/compare/v<%= "#{version.previous}...v#{version}" %>).
23+
<% end %>
24+
## SHA-256
25+
26+
If you'd like to verify that your gem is the same as the one I've uploaded,
27+
please use these SHA-256 hashes.
28+
29+
<% versions.each do |version| %>
30+
Here are the checksums for <%= version %>:
31+
32+
```
33+
$ shasum -a 256 *-<%= version %>.gem
34+
<%= `shasum -a 256 *-#{version}.gem` %>
35+
```
36+
37+
<% end %>
38+
As always, huge thanks to the many contributors who helped with this release.

0 commit comments

Comments
 (0)