|
200 | 200 | task release: %w(prep_release tag push)
|
201 | 201 | end
|
202 | 202 |
|
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) |
208 | 207 | end
|
209 | 208 |
|
210 |
| - sums = "$ shasum -a 256 *-#{version}.gem\n" + `shasum -a 256 *-#{version}.gem` |
| 209 | + def to_s |
| 210 | + @version |
| 211 | + end |
211 | 212 |
|
212 |
| - puts "Hi everyone," |
213 |
| - puts |
| 213 | + def previous |
| 214 | + @gem_version.segments[0, 3].tap { |v| v[2] -= 1 }.join(".") |
| 215 | + end |
214 | 216 |
|
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) } |
217 | 231 |
|
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?) |
221 | 233 |
|
222 |
| - if version =~ /rc/ |
| 234 | + if versions.any?(&:rc?) |
223 | 235 | require "date"
|
224 | 236 | future_date = Date.today + 5
|
225 | 237 | future_date += 1 while future_date.saturday? || future_date.sunday?
|
226 | 238 |
|
227 | 239 | 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 |
235 | 240 | end
|
236 | 241 |
|
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) |
267 | 245 | end
|
268 | 246 | end
|
0 commit comments