Skip to content

Commit ce0df82

Browse files
committed
Fix the update_versions release task
1 parent ade741e commit ce0df82

File tree

2 files changed

+23
-49
lines changed

2 files changed

+23
-49
lines changed

Rakefile

+1-27
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,7 @@ else
4646
end
4747

4848
desc 'Bump all versions to match version.rb'
49-
task :update_versions do
50-
require File.dirname(__FILE__) + "/version"
51-
52-
File.open("RAILS_VERSION", "w") do |f|
53-
f.puts Rails::VERSION::STRING
54-
end
55-
56-
constants = {
57-
"activesupport" => "ActiveSupport",
58-
"activemodel" => "ActiveModel",
59-
"actionpack" => "ActionPack",
60-
"actionview" => "ActionView",
61-
"actionmailer" => "ActionMailer",
62-
"activerecord" => "ActiveRecord",
63-
"railties" => "Rails"
64-
}
65-
66-
version_file = File.read("version.rb")
67-
68-
PROJECTS.each do |project|
69-
Dir["#{project}/lib/*/gem_version.rb"].each do |file|
70-
File.open(file, "w") do |f|
71-
f.write version_file.gsub(/Rails/, constants[project])
72-
end
73-
end
74-
end
75-
end
49+
task :update_versions => "all:update_versions"
7650

7751
# We have a webhook configured in GitHub that gets invoked after pushes.
7852
# This hook triggers the following tasks:

tasks/release.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,37 @@
1515
rm_f gem
1616
end
1717

18-
task :update_version_rb do
18+
task :update_versions do
1919
glob = root.dup
20-
glob << "/#{framework}/lib/*" unless framework == "rails"
21-
glob << "/version.rb"
20+
if framework == "rails"
21+
glob << "/version.rb"
22+
else
23+
glob << "/#{framework}/lib/*"
24+
glob << "/gem_version.rb"
25+
end
2226

2327
file = Dir[glob].first
2428
ruby = File.read(file)
2529

26-
if framework == "rails" || framework == "railties"
27-
major, minor, tiny, pre = version.split('.')
28-
pre = pre ? pre.inspect : "nil"
30+
major, minor, tiny, pre = version.split('.')
31+
pre = pre ? pre.inspect : "nil"
2932

30-
ruby.gsub!(/^(\s*)MAJOR(\s*)= .*?$/, "\\1MAJOR = #{major}")
31-
raise "Could not insert MAJOR in #{file}" unless $1
33+
ruby.gsub!(/^(\s*)MAJOR(\s*)= .*?$/, "\\1MAJOR = #{major}")
34+
raise "Could not insert MAJOR in #{file}" unless $1
3235

33-
ruby.gsub!(/^(\s*)MINOR(\s*)= .*?$/, "\\1MINOR = #{minor}")
34-
raise "Could not insert MINOR in #{file}" unless $1
36+
ruby.gsub!(/^(\s*)MINOR(\s*)= .*?$/, "\\1MINOR = #{minor}")
37+
raise "Could not insert MINOR in #{file}" unless $1
3538

36-
ruby.gsub!(/^(\s*)TINY(\s*)= .*?$/, "\\1TINY = #{tiny}")
37-
raise "Could not insert TINY in #{file}" unless $1
39+
ruby.gsub!(/^(\s*)TINY(\s*)= .*?$/, "\\1TINY = #{tiny}")
40+
raise "Could not insert TINY in #{file}" unless $1
3841

39-
ruby.gsub!(/^(\s*)PRE(\s*)= .*?$/, "\\1PRE = #{pre}")
40-
raise "Could not insert PRE in #{file}" unless $1
41-
else
42-
ruby.gsub!(/^(\s*)Gem::Version\.new .*?$/, "\\1Gem::Version.new \"#{version}\"")
43-
raise "Could not insert Gem::Version in #{file}" unless $1
44-
end
42+
ruby.gsub!(/^(\s*)PRE(\s*)= .*?$/, "\\1PRE = #{pre}")
43+
raise "Could not insert PRE in #{file}" unless $1
4544

4645
File.open(file, 'w') { |f| f.write ruby }
4746
end
4847

49-
task gem => %w(update_version_rb pkg) do
48+
task gem => %w(update_versions pkg) do
5049
cmd = ""
5150
cmd << "cd #{framework} && " unless framework == "rails"
5251
cmd << "gem build #{gemspec} && mv #{framework}-#{version}.gem #{root}/pkg/"
@@ -93,9 +92,10 @@
9392
end
9493

9594
namespace :all do
96-
task :build => FRAMEWORKS.map { |f| "#{f}:build" } + ['rails:build']
97-
task :install => FRAMEWORKS.map { |f| "#{f}:install" } + ['rails:install']
98-
task :push => FRAMEWORKS.map { |f| "#{f}:push" } + ['rails:push']
95+
task :build => FRAMEWORKS.map { |f| "#{f}:build" } + ['rails:build']
96+
task :update_versions => FRAMEWORKS.map { |f| "#{f}:update_versions" } + ['rails:update_versions']
97+
task :install => FRAMEWORKS.map { |f| "#{f}:install" } + ['rails:install']
98+
task :push => FRAMEWORKS.map { |f| "#{f}:push" } + ['rails:push']
9999

100100
task :ensure_clean_state do
101101
unless `git status -s | grep -v RAILS_VERSION`.strip.empty?

0 commit comments

Comments
 (0)