heroku-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +22 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +67 -0
- data/LICENSE +43 -0
- data/README.md +117 -0
- data/Rakefile +43 -0
- data/TODO +2 -0
- data/heroku-rails.gemspec +37 -0
- data/lib/heroku-rails.rb +9 -0
- data/lib/heroku/rails/config.rb +42 -0
- data/lib/heroku/rails/tasks.rb +224 -0
- data/lib/templates/heroku.example.yml +5 -0
- metadata +111 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Heroku Rails
|
2
|
+
v0.0.1
|
3
|
+
============================================
|
4
|
+
Initial fork and reorganization
|
5
|
+
|
6
|
+
|
7
|
+
Heroku Sans
|
8
|
+
v0.2.0
|
9
|
+
============================================
|
10
|
+
|
11
|
+
Elijah Miller
|
12
|
+
Fix newline error in gem manifest
|
13
|
+
Improve instructions
|
14
|
+
|
15
|
+
Glenn Roberts
|
16
|
+
Gem-ify it
|
17
|
+
Improve generation of gems manifest
|
18
|
+
|
19
|
+
|
20
|
+
v0.0.1.
|
21
|
+
============================================
|
22
|
+
Initial release.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
heroku-rails (0.0.1)
|
5
|
+
heroku
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
archive-tar-minitar (0.5.2)
|
11
|
+
autotest (4.4.1)
|
12
|
+
columnize (0.3.1)
|
13
|
+
configuration (1.1.0)
|
14
|
+
diff-lcs (1.1.2)
|
15
|
+
growl-glue (1.0.7)
|
16
|
+
heroku (1.11.0)
|
17
|
+
json_pure (>= 1.2.0, < 1.5.0)
|
18
|
+
launchy (~> 0.3.2)
|
19
|
+
rest-client (>= 1.4.0, < 1.7.0)
|
20
|
+
json_pure (1.4.6)
|
21
|
+
launchy (0.3.7)
|
22
|
+
configuration (>= 0.0.5)
|
23
|
+
rake (>= 0.8.1)
|
24
|
+
linecache (0.43)
|
25
|
+
linecache19 (0.5.11)
|
26
|
+
ruby_core_source (>= 0.1.4)
|
27
|
+
mime-types (1.16)
|
28
|
+
rake (0.8.7)
|
29
|
+
rest-client (1.6.1)
|
30
|
+
mime-types (>= 1.16)
|
31
|
+
rspec (2.0.1)
|
32
|
+
rspec-core (~> 2.0.1)
|
33
|
+
rspec-expectations (~> 2.0.1)
|
34
|
+
rspec-mocks (~> 2.0.1)
|
35
|
+
rspec-core (2.0.1)
|
36
|
+
rspec-expectations (2.0.1)
|
37
|
+
diff-lcs (>= 1.1.2)
|
38
|
+
rspec-mocks (2.0.1)
|
39
|
+
rspec-core (~> 2.0.1)
|
40
|
+
rspec-expectations (~> 2.0.1)
|
41
|
+
ruby-debug (0.10.3)
|
42
|
+
columnize (>= 0.1)
|
43
|
+
ruby-debug-base (~> 0.10.3.0)
|
44
|
+
ruby-debug-base (0.10.3)
|
45
|
+
linecache (>= 0.3)
|
46
|
+
ruby-debug-base19 (0.11.24)
|
47
|
+
columnize (>= 0.3.1)
|
48
|
+
linecache19 (>= 0.5.11)
|
49
|
+
ruby_core_source (>= 0.1.4)
|
50
|
+
ruby-debug19 (0.11.6)
|
51
|
+
columnize (>= 0.3.1)
|
52
|
+
linecache19 (>= 0.5.11)
|
53
|
+
ruby-debug-base19 (>= 0.11.19)
|
54
|
+
ruby_core_source (0.1.4)
|
55
|
+
archive-tar-minitar (>= 0.5.2)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
autotest
|
62
|
+
growl-glue
|
63
|
+
heroku
|
64
|
+
heroku-rails!
|
65
|
+
rspec (~> 2.0)
|
66
|
+
ruby-debug
|
67
|
+
ruby-debug19
|
data/LICENSE
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Heroku Rails License:
|
2
|
+
Copyright (c) 2010 Jacques Crocker
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
Heroku Sans License:
|
24
|
+
Copyright (c) 2008 Elijah Miller
|
25
|
+
|
26
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
27
|
+
a copy of this software and associated documentation files (the
|
28
|
+
"Software"), to deal in the Software without restriction, including
|
29
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
30
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
31
|
+
permit persons to whom the Software is furnished to do so, subject to
|
32
|
+
the following conditions:
|
33
|
+
|
34
|
+
The above copyright notice and this permission notice shall be
|
35
|
+
included in all copies or substantial portions of the Software.
|
36
|
+
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
38
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
39
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
40
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
41
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
42
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
43
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
Heroku Rails
|
2
|
+
=============
|
3
|
+
|
4
|
+
Easier configuration and deployment of Rails apps on Heroku
|
5
|
+
|
6
|
+
Configure your Heroku environment via a YML file (config/heroku.yml) that defines all your environments, addons, and environment variables.
|
7
|
+
|
8
|
+
Heroku Rails also handles asset packaging (via jammit), deployment of assets to s3 (via jammit-s3).
|
9
|
+
|
10
|
+
## Install
|
11
|
+
|
12
|
+
### Rails 3
|
13
|
+
|
14
|
+
Add this to your Gemfile:
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem 'heroku-rails'
|
18
|
+
end
|
19
|
+
|
20
|
+
### Rails 2
|
21
|
+
|
22
|
+
To install add the following to config/environment.rb:
|
23
|
+
|
24
|
+
config.gem 'heroku-rails'
|
25
|
+
|
26
|
+
Rake tasks are not automatically loaded from gems, so you’ll need to add the following to your Rakefile:
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'heroku/rails/tasks'
|
30
|
+
rescue LoadError
|
31
|
+
STDERR.puts "Run `rake gems:install` to install heroku-rails"
|
32
|
+
end
|
33
|
+
|
34
|
+
## Configure
|
35
|
+
|
36
|
+
In config/heroku.yml you will need add the Heroku apps that you would like to attach to this project. You can generate this file and edit it by running:
|
37
|
+
|
38
|
+
rake heroku:create_config
|
39
|
+
|
40
|
+
If this is a fresh project, heroku_san can create all the applications for
|
41
|
+
you, and set the RACK_ENV.
|
42
|
+
|
43
|
+
rake all heroku:create heroku:rack_env
|
44
|
+
|
45
|
+
## Usage
|
46
|
+
|
47
|
+
After configuring your Heroku apps you can use rake tasks to control the
|
48
|
+
apps.
|
49
|
+
|
50
|
+
rake production deploy
|
51
|
+
|
52
|
+
A rake task with the shorthand name of each app is now available and adds that
|
53
|
+
server to the list that subsequent commands will execute on. Because this list
|
54
|
+
is additive, you can easily select which servers to run a command on.
|
55
|
+
|
56
|
+
rake demo staging restart
|
57
|
+
|
58
|
+
A special rake task 'all' is created that causes any further commands to
|
59
|
+
execute on all heroku apps.
|
60
|
+
|
61
|
+
Manipulate collaborators on all this project's apps (prompts for email
|
62
|
+
address):
|
63
|
+
|
64
|
+
rake all heroku:share
|
65
|
+
rake all heroku:unshare
|
66
|
+
|
67
|
+
Need to add remotes for each app?
|
68
|
+
|
69
|
+
rake all heroku:remotes
|
70
|
+
|
71
|
+
A full list of tasks provided:
|
72
|
+
|
73
|
+
rake all # Select all Heroku apps for later command
|
74
|
+
rake console # Opens a remote console
|
75
|
+
rake deploy # Deploys, migrates and restarts latest code.
|
76
|
+
rake after_deploy # Callback run after the overall deploy
|
77
|
+
rake after_each_deploy # Callback run after each environment's deploy
|
78
|
+
rake before_deploy # Callback run before the overall deploy
|
79
|
+
rake before_each_deploy # Callback run before each environment's deploy
|
80
|
+
rake capture # Captures a bundle on Heroku
|
81
|
+
rake heroku:apps # Lists configured apps
|
82
|
+
rake heroku:create # Creates the Heroku app
|
83
|
+
rake heroku:create_config # Creates an example configuration file
|
84
|
+
rake heroku:gems # Generate the Heroku gems manifest from gem dependencies
|
85
|
+
rake heroku:remotes # Add git remotes for all apps in this project
|
86
|
+
rake heroku:rack_env # Add proper RACK_ENV to each application
|
87
|
+
rake heroku:share # Adds a collaborator
|
88
|
+
rake heroku:unshare # Removes a collaborator
|
89
|
+
rake migrate # Migrates and restarts remote servers
|
90
|
+
rake restart # Restarts remote servers
|
91
|
+
|
92
|
+
Frequently used tasks are not namespaced, everything else lives under heroku.
|
93
|
+
|
94
|
+
## About Heroku Rails
|
95
|
+
|
96
|
+
### Links
|
97
|
+
|
98
|
+
Homepage:: http://github.com/railsjedi/heroku-rails
|
99
|
+
Issue Tracker:: http://github.com/railsjedi/heroku-rails/issues
|
100
|
+
|
101
|
+
### License
|
102
|
+
|
103
|
+
License:: Copyright (c) 2010 [Jacques Crocker](mailto:railsjedi@gmail.com), released under the MIT license.
|
104
|
+
|
105
|
+
## Forked from Heroku Sans
|
106
|
+
|
107
|
+
Heroku Rails is a fork and rewrite/reorganiziation of Heroku Sans, and a nice simple set of Rake tasks for managing Heroku environments. Check out that project here: http://github.com/fastestforward/heroku_san
|
108
|
+
|
109
|
+
### Heroku Sans Contributors
|
110
|
+
|
111
|
+
* Elijah Miller (elijah.miller@gmail.com)
|
112
|
+
* Glenn Roberts (glenn.roberts@siyelo.com)
|
113
|
+
* Damien Mathieu (42@dmathieu.com)
|
114
|
+
|
115
|
+
### Heroku Sans License
|
116
|
+
|
117
|
+
License:: Copyright (c) 2009 Elijah Miller <mailto:elijah.miller@gmail.com>, released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
|
7
|
+
gemspec = eval(File.read('heroku-rails.gemspec'))
|
8
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
9
|
+
pkg.gem_spec = gemspec
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "build the gem and release it to rubygems.org"
|
13
|
+
task :release => :gem do
|
14
|
+
puts "Tagging #{gemspec.version}..."
|
15
|
+
system "git tag -a #{gemspec.version} -m 'Tagging #{gemspec.version}'"
|
16
|
+
puts "Pushing to Github..."
|
17
|
+
system "git push --tags"
|
18
|
+
puts "Pushing to rubygems.org..."
|
19
|
+
system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
20
|
+
end
|
21
|
+
|
22
|
+
require "rspec"
|
23
|
+
require "rspec/core/rake_task"
|
24
|
+
|
25
|
+
Rspec::Core::RakeTask.new(:spec) do |spec|
|
26
|
+
spec.pattern = "spec/**/*_spec.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
Rspec::Core::RakeTask.new('spec:progress') do |spec|
|
30
|
+
spec.rspec_opts = %w(--format progress)
|
31
|
+
spec.pattern = "spec/**/*_spec.rb"
|
32
|
+
end
|
33
|
+
|
34
|
+
require "rake/rdoctask"
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
rdoc.rdoc_dir = "rdoc"
|
37
|
+
rdoc.title = "Heroku Rails #{gemspec.version}"
|
38
|
+
rdoc.rdoc_files.include("README*")
|
39
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
task :default => :spec
|
data/TODO
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "heroku-rails"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
|
5
|
+
s.authors = ["Elijah Miller", "Glenn Roberts", "Jacques Crocker"]
|
6
|
+
s.summary = "A bunch of useful Rake tasks for managing your Heroku apps"
|
7
|
+
s.description = "Manage multiple Heroku instances/apps for a single Rails app using Rake"
|
8
|
+
|
9
|
+
s.email = "railsjedi@gmail.com"
|
10
|
+
s.homepage = "http://github.com/railsjedi/heroku-rails"
|
11
|
+
s.rubyforge_project = "none"
|
12
|
+
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.files = Dir['lib/**/*',
|
15
|
+
'spec/**/*',
|
16
|
+
'heroku-rails.gemspec',
|
17
|
+
'Gemfile',
|
18
|
+
'Gemfile.lock',
|
19
|
+
'CHANGELOG',
|
20
|
+
'LICENSE',
|
21
|
+
'Rakefile',
|
22
|
+
'README.md',
|
23
|
+
'TODO']
|
24
|
+
|
25
|
+
s.test_files = Dir['spec/**/*']
|
26
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
27
|
+
s.extra_rdoc_files = [
|
28
|
+
"LICENSE",
|
29
|
+
"README.md",
|
30
|
+
"TODO",
|
31
|
+
"CHANGELOG"
|
32
|
+
]
|
33
|
+
|
34
|
+
s.add_runtime_dependency("heroku")
|
35
|
+
s.add_development_dependency "rspec", "~> 2.0"
|
36
|
+
end
|
37
|
+
|
data/lib/heroku-rails.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Heroku
|
2
|
+
module Rails
|
3
|
+
class Config
|
4
|
+
|
5
|
+
attr_accessor :settings
|
6
|
+
|
7
|
+
def initialize(config_filepath)
|
8
|
+
if File.exists?(config_filepath)
|
9
|
+
self.settings = YAML.load_file(HEROKU_CONFIG_FILE)
|
10
|
+
else
|
11
|
+
self.settings = {}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# pull out the stack setting for a particular app environment
|
16
|
+
def stack(app = 'all')
|
17
|
+
# TODO
|
18
|
+
end
|
19
|
+
|
20
|
+
# pull out the config setting hash for a particular app environment
|
21
|
+
def config(app = 'all')
|
22
|
+
# TODO
|
23
|
+
end
|
24
|
+
|
25
|
+
# return a list of collaborators for a particular app environment
|
26
|
+
def collaborators(app = 'all')
|
27
|
+
# TODO
|
28
|
+
end
|
29
|
+
|
30
|
+
# return a list of domains for a particular app environment
|
31
|
+
def domains(app = 'all')
|
32
|
+
# TODO
|
33
|
+
end
|
34
|
+
|
35
|
+
# return a list of addons for a particular app environment
|
36
|
+
def addons(app = 'addons')
|
37
|
+
# TODO
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,224 @@
|
|
1
|
+
HEROKU_CONFIG_FILE = Rails.root.join('config', 'heroku.yml')
|
2
|
+
|
3
|
+
require 'heroku/rails/config'
|
4
|
+
HEROKU_CONFIG = Heroku::Rails::Config.new(HEROKU_CONFIG_FILE)
|
5
|
+
|
6
|
+
(HEROKU_CONFIG.settings['apps'] || []).each do |name, app|
|
7
|
+
desc "Select #{name} Heroku app for later commands"
|
8
|
+
task name do
|
9
|
+
@heroku_apps ||= []
|
10
|
+
@heroku_apps << name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Select all Heroku apps for later command'
|
15
|
+
task :all do
|
16
|
+
@heroku_apps = HEROKU_CONFIG.settings['apps'].keys
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :heroku do
|
20
|
+
desc "Creates the Heroku app"
|
21
|
+
task :create do
|
22
|
+
each_heroku_app do |name, app, repo|
|
23
|
+
system_with_echo "heroku create #{app}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Generate the Heroku gems manifest from gem dependencies"
|
28
|
+
task :gems => 'gems:base' do
|
29
|
+
RAILS_ENV='production'
|
30
|
+
Rake::Task[:environment].invoke
|
31
|
+
gems = Rails.configuration.gems.reject { |g| g.frozen? && !g.framework_gem? }
|
32
|
+
list = gems.collect do |g|
|
33
|
+
command, *options = g.send(:install_command)
|
34
|
+
options.join(" ")
|
35
|
+
end
|
36
|
+
|
37
|
+
list.unshift(%Q{rails --version "= #{Rails.version}"})
|
38
|
+
|
39
|
+
File.open(Rails.root.join('.gems'), 'w') do |f|
|
40
|
+
f.write(list.join("\n"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Add git remotes for all apps in this project'
|
45
|
+
task :remotes do
|
46
|
+
each_heroku_app do |name, app, repo|
|
47
|
+
system("git remote add #{name} #{repo}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Adds a collaborator'
|
52
|
+
task :share do
|
53
|
+
print "Email address of collaborator to add: "
|
54
|
+
$stdout.flush
|
55
|
+
email = $stdin.gets
|
56
|
+
each_heroku_app do |name, app, repo|
|
57
|
+
system_with_echo "heroku sharing:add --app #{app} #{email}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'Adds a collaborator'
|
62
|
+
task :unshare do
|
63
|
+
print "Email address of collaborator to remove: "
|
64
|
+
$stdout.flush
|
65
|
+
email = $stdin.gets
|
66
|
+
each_heroku_app do |name, app, repo|
|
67
|
+
system_with_echo "heroku sharing:remove --app #{app} #{email}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Lists configured apps'
|
72
|
+
task :apps => :all do
|
73
|
+
each_heroku_app do |name, app, repo|
|
74
|
+
puts "#{name} is shorthand for the Heroku app #{app} located at:"
|
75
|
+
puts " #{repo}"
|
76
|
+
puts
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc 'Add proper RACK_ENV to each application'
|
81
|
+
task :rack_env => :all do
|
82
|
+
each_heroku_app do |name, app, repo|
|
83
|
+
command = "heroku config --app #{app}"
|
84
|
+
puts command
|
85
|
+
config = Hash[`#{command}`.scan(/^(.+?)\s*=>\s*(.+)$/)]
|
86
|
+
if config['RACK_ENV'] != name
|
87
|
+
system_with_echo "heroku config:add --app #{app} RACK_ENV=#{name}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
desc 'Creates an example configuration file'
|
93
|
+
task :create_config do
|
94
|
+
example = File.join(File.dirname(__FILE__), '..', 'templates', 'heroku.example.yml')
|
95
|
+
if File.exists?(HEROKU_CONFIG_FILE)
|
96
|
+
puts "config/heroku.yml already exists"
|
97
|
+
else
|
98
|
+
puts "Copied example config to config/heroku.yml"
|
99
|
+
FileUtils.cp(example, HEROKU_CONFIG_FILE)
|
100
|
+
system_with_echo("#{ENV['EDITOR']} #{HEROKU_CONFIG_FILE}")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
namespace :setup do
|
105
|
+
# TODO
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "Deploys, migrates and restarts latest code"
|
111
|
+
task :deploy => :before_deploy do
|
112
|
+
each_heroku_app do |name, app, repo|
|
113
|
+
@heroku_app = {:name => name, :app => app, :repo => repo}
|
114
|
+
Rake::Task[:before_each_deploy].invoke
|
115
|
+
branch = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
|
116
|
+
if branch.present?
|
117
|
+
@git_push_arguments ||= []
|
118
|
+
system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{branch}:master && heroku rake --app #{app} db:migrate && heroku restart --app #{app}"
|
119
|
+
else
|
120
|
+
puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy"
|
121
|
+
exit(1)
|
122
|
+
end
|
123
|
+
Rake::Task[:after_each_deploy].invoke
|
124
|
+
end
|
125
|
+
Rake::Task[:after_deploy].execute
|
126
|
+
end
|
127
|
+
|
128
|
+
desc "Callback before all deploys"
|
129
|
+
task :before_deploy do
|
130
|
+
end
|
131
|
+
|
132
|
+
desc "Callback after all deploys"
|
133
|
+
task :after_deploy do
|
134
|
+
end
|
135
|
+
|
136
|
+
desc "Callback before each deploy"
|
137
|
+
task :before_each_deploy do
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Callback after each deploy"
|
141
|
+
task :after_each_deploy do
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
desc "Force deploys, migrates and restarts latest code"
|
146
|
+
task :force_deploy do
|
147
|
+
@git_push_arguments ||= []
|
148
|
+
@git_push_arguments << '--force'
|
149
|
+
Rake::Task[:deploy].execute
|
150
|
+
end
|
151
|
+
|
152
|
+
desc "Captures a bundle on Heroku"
|
153
|
+
task :capture do
|
154
|
+
each_heroku_app do |name, app, repo|
|
155
|
+
system_with_echo "heroku bundles:capture --app #{app}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
desc "Opens a remote console"
|
160
|
+
task :console do
|
161
|
+
each_heroku_app do |name, app, repo|
|
162
|
+
system_with_echo "heroku console --app #{app}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
desc "Restarts remote servers"
|
167
|
+
task :restart do
|
168
|
+
each_heroku_app do |name, app, repo|
|
169
|
+
system_with_echo "heroku restart --app #{app}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
desc "Migrates and restarts remote servers"
|
174
|
+
task :migrate do
|
175
|
+
each_heroku_app do |name, app, repo|
|
176
|
+
system_with_echo "heroku rake --app #{app} db:migrate && heroku restart --app #{app}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
namespace :db do
|
181
|
+
task :pull do
|
182
|
+
each_heroku_app do |name, app, repo|
|
183
|
+
system_with_echo "heroku pgdumps:capture --app #{app}"
|
184
|
+
dump = `heroku pgdumps --app #{app}`.split("\n").last.split(" ").first
|
185
|
+
system_with_echo "mkdir -p #{Rails.root}/db/dumps"
|
186
|
+
file = "#{Rails.root}/db/dumps/#{dump}.sql.gz"
|
187
|
+
url = `heroku pgdumps:url --app #{app} #{dump}`.chomp
|
188
|
+
system_with_echo "wget", url, "-O", file
|
189
|
+
system_with_echo "rake db:drop db:create"
|
190
|
+
system_with_echo "gunzip -c #{file} | #{Rails.root}/script/dbconsole"
|
191
|
+
system_with_echo "rake jobs:clear"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def system_with_echo(*args)
|
197
|
+
puts args.join(' ')
|
198
|
+
system(*args)
|
199
|
+
end
|
200
|
+
|
201
|
+
def each_heroku_app
|
202
|
+
if @heroku_apps.blank? && HEROKU_CONFIG.settings['apps'].size == 1
|
203
|
+
app = HEROKU_CONFIG.settings['apps'].keys.first
|
204
|
+
puts "Defaulting to #{app} app since only one app is defined"
|
205
|
+
@heroku_apps = [app]
|
206
|
+
end
|
207
|
+
if @heroku_apps.present?
|
208
|
+
@heroku_apps.each do |name|
|
209
|
+
app = HEROKU_CONFIG.settings['apps'][name]
|
210
|
+
yield(name, app, "git@heroku.com:#{app}.git")
|
211
|
+
end
|
212
|
+
puts
|
213
|
+
else
|
214
|
+
puts "You must first specify at least one Heroku app:
|
215
|
+
rake <app> [<app>] <command>
|
216
|
+
rake production restart
|
217
|
+
rake demo staging deploy"
|
218
|
+
|
219
|
+
puts "\nYou can use also command all Heroku apps for this project:
|
220
|
+
rake all heroku:share"
|
221
|
+
|
222
|
+
exit(1)
|
223
|
+
end
|
224
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Elijah Miller
|
14
|
+
- Glenn Roberts
|
15
|
+
- Jacques Crocker
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-11-01 00:00:00 -07:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
name: heroku
|
27
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
hash: 3
|
33
|
+
segments:
|
34
|
+
- 0
|
35
|
+
version: "0"
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
name: rspec
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 0
|
50
|
+
version: "2.0"
|
51
|
+
requirement: *id002
|
52
|
+
description: Manage multiple Heroku instances/apps for a single Rails app using Rake
|
53
|
+
email: railsjedi@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files:
|
59
|
+
- LICENSE
|
60
|
+
- README.md
|
61
|
+
- TODO
|
62
|
+
- CHANGELOG
|
63
|
+
files:
|
64
|
+
- lib/heroku/rails/config.rb
|
65
|
+
- lib/heroku/rails/tasks.rb
|
66
|
+
- lib/heroku-rails.rb
|
67
|
+
- lib/templates/heroku.example.yml
|
68
|
+
- heroku-rails.gemspec
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- CHANGELOG
|
72
|
+
- LICENSE
|
73
|
+
- Rakefile
|
74
|
+
- README.md
|
75
|
+
- TODO
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: http://github.com/railsjedi/heroku-rails
|
78
|
+
licenses: []
|
79
|
+
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options:
|
82
|
+
- --charset=UTF-8
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: none
|
106
|
+
rubygems_version: 1.3.7
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: A bunch of useful Rake tasks for managing your Heroku apps
|
110
|
+
test_files: []
|
111
|
+
|