Publish Action Cable to NPM when we release.

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
This commit is contained in:
Jon Moss 2016-05-07 10:41:23 -04:00 committed by Jeremy Daer
parent d1794cd88c
commit 548c1d6e8b
No known key found for this signature in database
GPG Key ID: AB8F6399D5C60664
4 changed files with 75 additions and 8 deletions

@ -103,18 +103,24 @@ branch.
Run `rake install` to generate the gems and install them locally. Then try
generating a new app and ensure that nothing explodes.
Verify that Action Cable's package.json is updated with the RC version.
This will stop you from looking silly when you push an RC to rubygems.org and
then realize it is broken.
### Release the gem.
### Release to RubyGems and NPM.
IMPORTANT: Due to YAML parse problems on the rubygems.org server, it is safest
to use Ruby 1.8 when releasing.
IMPORTANT: The Action Cable client is released as an NPM package, so you must
have Node.js installed, have an NPM account (npmjs.com), and be an actioncable
package owner (`npm owner ls actioncable`) to do a full release. Do not release
until you're set up with NPM!
Run `rake release`. This will populate the gemspecs with data from
RAILS_VERSION, commit the changes, tag it, and push the gems to rubygems.org.
Here are the commands that `rake release` should use, so you can understand
what to do in case anything goes wrong:
Run `rake release`. This will populate the gemspecs and NPM package.json with
the current RAILS_VERSION, commit the changes, tag it, and push the gems to
rubygems.org.
Here are the commands that `rake release` uses so you can understand what to do
in case anything goes wrong:
```
$ rake all:build
@ -122,7 +128,7 @@ $ git commit -am'updating RAILS_VERSION'
$ git tag -m 'v3.0.10.rc1 release' v3.0.10.rc1
$ git push
$ git push --tags
$ for i in $(ls pkg); do gem push $i; done
$ for i in $(ls pkg); do gem push $i; npm publish; done
```
### Send Rails release announcements

@ -33,3 +33,9 @@
if @debugging
messages.push(Date.now())
console.log("[ActionCable]", messages...)
# NOTE: We expose ActionCable as a browser global so we can reference it
# internally without concern for how the module is loaded.
window?.ActionCable = @ActionCable
module?.exports = @ActionCable

24
actioncable/package.json Normal file

@ -0,0 +1,24 @@
{
"name": "actioncable",
"version": "5.0.0-rc1",
"description": "WebSocket framework for Ruby on Rails.",
"main": "lib/assets/compiled/action_cable.js",
"files": [
"lib/assets/compiled/*.js"
],
"repository": {
"type": "git",
"url": "rails/rails"
},
"keywords": [
"websockets",
"actioncable",
"rails"
],
"author": "David Heinemeier Hansson <david@loudthinking.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/rails/rails/issues"
},
"homepage": "http://rubyonrails.org/"
}

@ -44,6 +44,36 @@
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 @@
task :push => :build do
sh "gem push #{gem}"
sh "npm publish" if File.exist?("#{framework}/package.json")
end
end
end