aboutsummaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-05-07 10:41:23 -0400
committerJeremy Daer <jeremydaer@gmail.com>2016-05-11 19:36:27 -0700
commit548c1d6e8b819ca4e02e6218b67107c580ee65f2 (patch)
treef97595c9f2982d2335ddfc36e51a7e38381b4ab5 /tasks
parentd1794cd88c1de2f72ba35fd5cced42bc0f7528f9 (diff)
downloadrails-548c1d6e8b819ca4e02e6218b67107c580ee65f2.tar.gz
rails-548c1d6e8b819ca4e02e6218b67107c580ee65f2.tar.bz2
rails-548c1d6e8b819ca4e02e6218b67107c580ee65f2.zip
Publish Action Cable to NPM when we release.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Diffstat (limited to 'tasks')
-rw-r--r--tasks/release.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/tasks/release.rb b/tasks/release.rb
index 61b44a4c56..e54b03eafa 100644
--- a/tasks/release.rb
+++ b/tasks/release.rb
@@ -44,6 +44,36 @@ directory "pkg"
raise "Could not insert PRE in #{file}" unless $1
File.open(file, 'w') { |f| f.write ruby }
+
+ if File.exist?("#{framework}/package.json")
+ Dir.chdir("#{framework}") do
+ # This "npm-ifies" the current version
+ # With npm, versions such as "5.0.0.rc1" or "5.0.0.beta1.1" are not compliant with its
+ # versioning system, so they must be transformed to "5.0.0-rc1" and "5.0.0-beta1-1" respectively.
+
+ # In essence, the code below runs through all "."s that appear in the version,
+ # and checks to see if their index in the version string is greater than or equal to 2,
+ # and if so, it will change the "." to a "-".
+
+ # Sample version transformations:
+ # irb(main):001:0> version = "5.0.1.1"
+ # => "5.0.1.1"
+ # irb(main):002:0> version.gsub(/\./).with_index { |s, i| i >= 2 ? '-' : s }
+ # => "5.0.1-1"
+ # irb(main):003:0> version = "5.0.0.rc1"
+ # => "5.0.0.rc1"
+ # irb(main):004:0> version.gsub(/\./).with_index { |s, i| i >= 2 ? '-' : s }
+ # => "5.0.0-rc1"
+ version = version.gsub(/\./).with_index { |s, i| i >= 2 ? '-' : s }
+
+ # Check if npm is installed, and raise an error if not
+ if sh 'which npm'
+ sh "npm version #{version} --no-git-tag-version"
+ else
+ raise 'You must have npm installed to release Rails.'
+ end
+ end
+ end
end
task gem => %w(update_versions pkg) do
@@ -61,6 +91,7 @@ directory "pkg"
task :push => :build do
sh "gem push #{gem}"
+ sh "npm publish" if File.exist?("#{framework}/package.json")
end
end
end