From 548c1d6e8b819ca4e02e6218b67107c580ee65f2 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 7 May 2016 10:41:23 -0400 Subject: Publish Action Cable to NPM when we release. Signed-off-by: Jeremy Daer --- tasks/release.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tasks') 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 -- cgit v1.2.3