Skip to content
Permalink
Browse files

Publish Action Cable to NPM when we release.

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
  • Loading branch information
maclover7 authored and jeremy committed May 7, 2016
1 parent d1794cd commit 548c1d6e8b819ca4e02e6218b67107c580ee65f2
Showing with 75 additions and 8 deletions.
  1. +14 −8 RELEASING_RAILS.md
  2. +6 −0 actioncable/app/assets/javascripts/action_cable.coffee.erb
  3. +24 −0 actioncable/package.json
  4. +31 −0 tasks/release.rb
@@ -103,26 +103,32 @@ 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: 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!

IMPORTANT: Due to YAML parse problems on the rubygems.org server, it is safest
to use Ruby 1.8 when releasing.
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.

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:
Here are the commands that `rake release` uses so you can understand what to do
in case anything goes wrong:

```
$ rake all:build
$ 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
@@ -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

0 comments on commit 548c1d6

Please sign in to comment.
You can’t perform that action at this time.