capistrano-helpers 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +174 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/capistrano-helpers.gemspec +63 -0
- data/lib/capistrano-helpers/branch.rb +14 -0
- data/lib/capistrano-helpers/campfire.rb +31 -0
- data/lib/capistrano-helpers/features.rb +33 -0
- data/lib/capistrano-helpers/gems.rb +14 -0
- data/lib/capistrano-helpers/git.rb +17 -0
- data/lib/capistrano-helpers/migrations.rb +8 -0
- data/lib/capistrano-helpers/passenger.rb +12 -0
- data/lib/capistrano-helpers/php.rb +15 -0
- data/lib/capistrano-helpers/preflight.rb +23 -0
- data/lib/capistrano-helpers/privates.rb +19 -0
- data/lib/capistrano-helpers/shared.rb +19 -0
- data/lib/capistrano-helpers/specs.rb +33 -0
- data/lib/capistrano-helpers/version.rb +15 -0
- data/lib/capistrano-helpers.rb +15 -0
- data/test/capistrano-helpers_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +88 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 West Arete Computing, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
= capistrano-helpers
|
2
|
+
|
3
|
+
A set of optional extensions to capistrano to make common tasks easier and
|
4
|
+
reduce redundancy across your deployments.
|
5
|
+
|
6
|
+
== Usage
|
7
|
+
|
8
|
+
In your capistrano deploy recipe, simply require the helpers that contain the
|
9
|
+
functionality that you would like to add to your recipe. In most cases this
|
10
|
+
also takes care of adding the hook so that the action takes place at the right
|
11
|
+
time during deployment.
|
12
|
+
|
13
|
+
Here's an example config/deploy.rb that uses a few helpers:
|
14
|
+
|
15
|
+
require 'capistrano-helpers/passenger' # Support for Apache passenger
|
16
|
+
require 'capistrano-helpers/specs' # Check specs before deploying
|
17
|
+
require 'capistrano-helpers/version' # Record the version number after deploying
|
18
|
+
require 'capistrano-helpers/campfire' # Post deploy info to campfire
|
19
|
+
|
20
|
+
# The name of the application.
|
21
|
+
set :application, "myapp"
|
22
|
+
|
23
|
+
# The source code management software to use.
|
24
|
+
set :scm, "git"
|
25
|
+
|
26
|
+
# Location of the source code.
|
27
|
+
set :repository, "git@github.com:mycompany/myapp.git"
|
28
|
+
|
29
|
+
That's it! The recipe will now also perform the actions described by the
|
30
|
+
helpers (in this case, the campfire helper also requires the tinder gem and
|
31
|
+
a config/campfire.yml file).
|
32
|
+
|
33
|
+
== Helpers
|
34
|
+
|
35
|
+
=== branch
|
36
|
+
|
37
|
+
Prompts the user for the particular tag/branch/commit to deploy.
|
38
|
+
|
39
|
+
=== campfire
|
40
|
+
|
41
|
+
After the application has been deployed, this helper will post a message to
|
42
|
+
the given campfire room stating the username, the application, the branch/tag,
|
43
|
+
and the environment. E.g.:
|
44
|
+
|
45
|
+
woods just deployed myapp v0.5.4 to staging
|
46
|
+
|
47
|
+
This helper expects to find a configuration file config/campfire.yml with the
|
48
|
+
following format:
|
49
|
+
|
50
|
+
# Configuration for posting to campfire.
|
51
|
+
account: mycompany
|
52
|
+
email: smithers@mycompany.com
|
53
|
+
password: 's3kret!'
|
54
|
+
room: Chatter
|
55
|
+
|
56
|
+
You can override the location of the configuration file by setting the
|
57
|
+
:campfire_config variable:
|
58
|
+
|
59
|
+
set :campfire_config, 'somewhere/else.yml'
|
60
|
+
|
61
|
+
This helper requires that the "tinder" gem is installed on the machine that
|
62
|
+
you run the "cap" command from. It doesn't need to be installed on any of the
|
63
|
+
servers. You can install the tinder gem using the following command on linux
|
64
|
+
or mac:
|
65
|
+
|
66
|
+
sudo gem install tinder
|
67
|
+
|
68
|
+
=== features
|
69
|
+
|
70
|
+
Before the app is deployed, this helper checks out the branch/tag that is
|
71
|
+
being deployed and runs all the cucumber features, ensuring that they all
|
72
|
+
pass.
|
73
|
+
|
74
|
+
== gems
|
75
|
+
|
76
|
+
Run the gems:install rake task using sudo after deployment.
|
77
|
+
|
78
|
+
== git
|
79
|
+
|
80
|
+
Set git as the repository type, and set up remote caching to speed up
|
81
|
+
deployments.
|
82
|
+
|
83
|
+
== migrations
|
84
|
+
|
85
|
+
Always run migrations during deployment.
|
86
|
+
|
87
|
+
=== passenger
|
88
|
+
|
89
|
+
Overrides the default :restart task so that it's compatible with restarting
|
90
|
+
apache/passenger (aka mod_rails). Touches tmp/restart.txt.
|
91
|
+
|
92
|
+
=== php
|
93
|
+
|
94
|
+
Use this helper when using capistrano to deploy a purely PHP application.
|
95
|
+
|
96
|
+
This neuters the default :restart and :finalize_updates tasks, since they
|
97
|
+
aren't typically needed for a PHP installation.
|
98
|
+
|
99
|
+
=== preflight
|
100
|
+
|
101
|
+
Goes through a set of yes/no questions with the user before the application is
|
102
|
+
actually deployed. This provides a way to walk the user through a set of
|
103
|
+
reminders. The deploy only proceeds if the user answers each question
|
104
|
+
affirmatively.
|
105
|
+
|
106
|
+
This helper expects to find the questions in a configuration file called
|
107
|
+
config/preflight.yml . The file should be in the following format:
|
108
|
+
|
109
|
+
# Questions that must be answered "yes" before a deploy is allowed to proceed.
|
110
|
+
- Does cruise control show all tests passing?
|
111
|
+
- Do the staging and production servers have the required gems installed?
|
112
|
+
- Are you prepared to run migrations on the remote server?
|
113
|
+
- Have you tagged this release?
|
114
|
+
- Have you pushed the tags to github?
|
115
|
+
|
116
|
+
You can override the location of the configuration file by setting the
|
117
|
+
:preflight_config variable:
|
118
|
+
|
119
|
+
set :preflight_config, 'somewhere/else.yml'
|
120
|
+
|
121
|
+
=== shared
|
122
|
+
|
123
|
+
During deployment, this helper replaces each of the given paths with a
|
124
|
+
symbolic link that points to the same path under the "shared" directory on the
|
125
|
+
server. This is useful for setting up files and directories that contain
|
126
|
+
data that should persist across deployments (uploads, for example).
|
127
|
+
|
128
|
+
After requiring this helper, set the paths to be symlinked using the
|
129
|
+
:shared variable:
|
130
|
+
|
131
|
+
set :shared, %w{
|
132
|
+
public/uploads
|
133
|
+
public/downloads/huge_files
|
134
|
+
}
|
135
|
+
|
136
|
+
This will create two symbolic links on the production server:
|
137
|
+
|
138
|
+
#{release_path}/public/uploads -> #{shared_path}/public/uploads
|
139
|
+
#{release_path}/public/downloads/huge_files -> #{shared_path}/public/downloads/huge_files
|
140
|
+
|
141
|
+
=== privates
|
142
|
+
|
143
|
+
This works much like the shared helper above, except the symbolic link will
|
144
|
+
point to the same path under "shared/private" on the server. This allows you
|
145
|
+
to set special permissions on that directory for keeping particularly
|
146
|
+
sensitive files safe, such as those that contain passwords or encryption keys.
|
147
|
+
|
148
|
+
After requiring this helper, set the paths to be symlinked using the
|
149
|
+
:privates variable:
|
150
|
+
|
151
|
+
set :privates, %w{
|
152
|
+
config/database.yml
|
153
|
+
config/session_secret.txt
|
154
|
+
}
|
155
|
+
|
156
|
+
This will create two symbolic links on the production server:
|
157
|
+
|
158
|
+
#{release_path}/config/database.yml -> #{shared_path}/private/config/database.yml
|
159
|
+
#{release_path}/config/session_secret.txt -> #{shared_path}/private/config/session_secret.txt
|
160
|
+
|
161
|
+
=== specs
|
162
|
+
|
163
|
+
Before the app is deployed, this helper checks out the branch/tag that is
|
164
|
+
being deployed and runs all the rspec specs, ensuring that they all pass.
|
165
|
+
|
166
|
+
=== version
|
167
|
+
|
168
|
+
Creates a VERSION file in the deployed copy that contains the name of the
|
169
|
+
branch/tag that was deployed. Useful for displaying version information in the
|
170
|
+
app itself.
|
171
|
+
|
172
|
+
== Copyright
|
173
|
+
|
174
|
+
Copyright (c) 2009 West Arete Computing, Inc.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "capistrano-helpers"
|
8
|
+
gem.summary = %Q{A set of optional extensions to capistrano to make common tasks easier.}
|
9
|
+
gem.description = %Q{A set of optional extensions to capistrano to make common tasks easier.}
|
10
|
+
gem.email = "scott@westarete.com"
|
11
|
+
gem.homepage = "http://github.com/westarete/capistrano-helpers"
|
12
|
+
gem.authors = ["Scott Woods"]
|
13
|
+
gem.add_dependency('capistrano', '>= 2.0.0')
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "capistrano-helpers #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{capistrano-helpers}
|
5
|
+
s.version = "0.3.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Scott Woods"]
|
9
|
+
s.date = %q{2009-11-04}
|
10
|
+
s.description = %q{A set of optional extensions to capistrano to make common tasks easier.}
|
11
|
+
s.email = %q{scott@westarete.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".document",
|
18
|
+
".gitignore",
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"capistrano-helpers.gemspec",
|
24
|
+
"lib/capistrano-helpers.rb",
|
25
|
+
"lib/capistrano-helpers/branch.rb",
|
26
|
+
"lib/capistrano-helpers/campfire.rb",
|
27
|
+
"lib/capistrano-helpers/features.rb",
|
28
|
+
"lib/capistrano-helpers/gems.rb",
|
29
|
+
"lib/capistrano-helpers/git.rb",
|
30
|
+
"lib/capistrano-helpers/migrations.rb",
|
31
|
+
"lib/capistrano-helpers/passenger.rb",
|
32
|
+
"lib/capistrano-helpers/php.rb",
|
33
|
+
"lib/capistrano-helpers/preflight.rb",
|
34
|
+
"lib/capistrano-helpers/privates.rb",
|
35
|
+
"lib/capistrano-helpers/shared.rb",
|
36
|
+
"lib/capistrano-helpers/specs.rb",
|
37
|
+
"lib/capistrano-helpers/version.rb",
|
38
|
+
"test/capistrano-helpers_test.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/westarete/capistrano-helpers}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.5}
|
45
|
+
s.summary = %q{A set of optional extensions to capistrano to make common tasks easier.}
|
46
|
+
s.test_files = [
|
47
|
+
"test/capistrano-helpers_test.rb",
|
48
|
+
"test/test_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 2.0.0"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<capistrano>, [">= 2.0.0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<capistrano>, [">= 2.0.0"])
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
desc "Ensure that a branch has been selected."
|
6
|
+
task :set_branch do
|
7
|
+
if !exists?(:branch)
|
8
|
+
set(:branch, Capistrano::CLI.ui.ask("Which tag/branch/commit? "))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
on :start, :set_branch
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
begin
|
4
|
+
# Campfire API gem for deploy notifications.
|
5
|
+
require 'tinder'
|
6
|
+
rescue LoadError
|
7
|
+
abort "The campfire helper requires the tinder gem. Install it with: sudo gem install tinder"
|
8
|
+
end
|
9
|
+
|
10
|
+
CapistranoHelpers.with_configuration do
|
11
|
+
|
12
|
+
namespace :deploy do
|
13
|
+
desc 'Make a post to campfire to tell everyone about this deployment.'
|
14
|
+
task :post_to_campfire do
|
15
|
+
if !exists?(:application)
|
16
|
+
puts "You should set :application to the name of this app."
|
17
|
+
end
|
18
|
+
username = `whoami`.chomp
|
19
|
+
config_file = fetch(:campfire_config, 'config/campfire.yml')
|
20
|
+
config = YAML::load_file(config_file)
|
21
|
+
campfire = Tinder::Campfire.new(config['account'])
|
22
|
+
campfire.login(config['email'], config['password'])
|
23
|
+
room = campfire.find_room_by_name(config['room'])
|
24
|
+
room.speak("#{username} just deployed #{application} #{branch} to #{stage}")
|
25
|
+
room.leave
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
after "deploy:restart", "deploy:post_to_campfire"
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
require File.dirname(__FILE__) + '/branch'
|
3
|
+
|
4
|
+
CapistranoHelpers.with_configuration do
|
5
|
+
|
6
|
+
namespace :deploy do
|
7
|
+
desc "Make sure all features pass"
|
8
|
+
task :check_features do
|
9
|
+
if scm != 'git'
|
10
|
+
abort "Sorry, you can only check features if you're using git as your scm."
|
11
|
+
end
|
12
|
+
`git branch` =~ /^\* ([^\s]+)/ or abort "Couldn't understand the output of `git branch`."
|
13
|
+
original_branch = $1
|
14
|
+
begin
|
15
|
+
puts "Checking out #{branch}"
|
16
|
+
system("git checkout #{branch}") or raise "Couldn't check out #{branch}."
|
17
|
+
puts "Checking features..."
|
18
|
+
system("rake features") or raise "One or more features are failing. Come back when they all pass."
|
19
|
+
@failed = false
|
20
|
+
rescue Exception => e
|
21
|
+
puts e
|
22
|
+
@failed = true
|
23
|
+
ensure
|
24
|
+
puts "Going back to branch #{original_branch}"
|
25
|
+
system("git checkout #{original_branch}") or abort "Sorry, couldn't put you back to your original branch."
|
26
|
+
end
|
27
|
+
abort if @failed
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
before "deploy:update_code", "deploy:check_features"
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :gems do
|
6
|
+
desc "Install gems on the remote server."
|
7
|
+
task :install, :roles => :app do
|
8
|
+
run "cd #{current_release} && #{sudo} rake gems:install RAILS_ENV=#{rails_env}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
after "deploy:update_code", "gems:install"
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
# The source code management software to use.
|
6
|
+
set :scm, "git"
|
7
|
+
|
8
|
+
# Rather than cloning from github each time, keep a local repo on the server
|
9
|
+
# and fetch from that instead. Much faster.
|
10
|
+
set :deploy_via, :remote_cache
|
11
|
+
|
12
|
+
# By default, it tries to keep git quiet. But this makes older version of
|
13
|
+
# git (like those on our servers) barf, since they don't always support the
|
14
|
+
# quiet options.
|
15
|
+
set :scm_verbose, true
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
desc 'Restart passenger'
|
7
|
+
task :restart, :roles => :app do
|
8
|
+
run "touch #{release_path}/tmp/restart.txt"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
task :restart do
|
7
|
+
# No need to restart the web server.
|
8
|
+
end
|
9
|
+
|
10
|
+
task :finalize_update do
|
11
|
+
# No need to make any extra symlinks.
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
desc 'Go through the preflight checklist'
|
7
|
+
task :preflight do
|
8
|
+
puts 'Going through preflight checklist:'
|
9
|
+
config_file = fetch(:preflight_config, 'config/preflight.yml')
|
10
|
+
questions = YAML::load_file(config_file)
|
11
|
+
questions.map! { |q| " * #{q} " }
|
12
|
+
questions.each do |question|
|
13
|
+
response = Capistrano::CLI.ui.ask(question)
|
14
|
+
if response !~ /y(es)?/i
|
15
|
+
abort 'Come back when you can answer "yes" to all the deploy questions.'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
before "deploy:update_code", "deploy:preflight"
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
desc 'Replace named files with a symlink to their counterparts in shared/private/'
|
7
|
+
task :symlink_privates do
|
8
|
+
if !exists?(:privates)
|
9
|
+
abort 'You must specify which privates to symlink using the "set :privates" command.'
|
10
|
+
end
|
11
|
+
privates.each do |path|
|
12
|
+
run "ln -nfs #{shared_path}/private/#{path} #{release_path}/#{path}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after "deploy:update_code", "deploy:symlink_privates"
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
|
3
|
+
CapistranoHelpers.with_configuration do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
desc 'Replace named files with a symlink to their counterparts in shared/'
|
7
|
+
task :symlink_shared do
|
8
|
+
if !exists?(:shared)
|
9
|
+
abort 'You must specify which files to symlink using the "set :shared" command.'
|
10
|
+
end
|
11
|
+
shared.each do |path|
|
12
|
+
run "ln -nfs #{shared_path}/#{path} #{release_path}/#{path}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after "deploy:update_code", "deploy:symlink_shared"
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
require File.dirname(__FILE__) + '/branch'
|
3
|
+
|
4
|
+
CapistranoHelpers.with_configuration do
|
5
|
+
|
6
|
+
namespace :deploy do
|
7
|
+
desc "Make sure all specs pass"
|
8
|
+
task :check_specs do
|
9
|
+
if scm != 'git'
|
10
|
+
abort "Sorry, you can only check specs if you're using git as your scm."
|
11
|
+
end
|
12
|
+
`git branch` =~ /^\* ([^\s]+)/ or abort "Couldn't understand the output of `git branch`."
|
13
|
+
original_branch = $1
|
14
|
+
begin
|
15
|
+
puts "Checking out #{branch}"
|
16
|
+
system("git checkout #{branch}") or raise "Couldn't check out #{branch}."
|
17
|
+
puts "Checking specs..."
|
18
|
+
system("rake spec") or raise "One or more specs are failing. Come back when they all pass."
|
19
|
+
@failed = false
|
20
|
+
rescue Exception => e
|
21
|
+
puts e
|
22
|
+
@failed = true
|
23
|
+
ensure
|
24
|
+
puts "Going back to branch #{original_branch}"
|
25
|
+
system("git checkout #{original_branch}") or abort "Sorry, couldn't put you back to your original branch."
|
26
|
+
end
|
27
|
+
abort if @failed
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
before "deploy:update_code", "deploy:check_specs"
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
|
2
|
+
require File.dirname(__FILE__) + '/branch'
|
3
|
+
|
4
|
+
CapistranoHelpers.with_configuration do
|
5
|
+
|
6
|
+
namespace :deploy do
|
7
|
+
desc "Write the name of the tag that we're deploying to a VERSION file"
|
8
|
+
task :write_version_file do
|
9
|
+
run "echo -n \"#{branch}\" > #{release_path}/VERSION"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after "deploy:update_code", "deploy:write_version_file"
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
4
|
+
abort "capistrano-helpers requires Capistrano 2"
|
5
|
+
end
|
6
|
+
|
7
|
+
class CapistranoHelpers
|
8
|
+
|
9
|
+
# Execute the given block of code within the context of the capistrano
|
10
|
+
# configuration.
|
11
|
+
def self.with_configuration(&block)
|
12
|
+
Capistrano::Configuration.instance(:must_exist).load(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Woods
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-04 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: capistrano
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.0
|
24
|
+
version:
|
25
|
+
description: A set of optional extensions to capistrano to make common tasks easier.
|
26
|
+
email: scott@westarete.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- capistrano-helpers.gemspec
|
42
|
+
- lib/capistrano-helpers.rb
|
43
|
+
- lib/capistrano-helpers/branch.rb
|
44
|
+
- lib/capistrano-helpers/campfire.rb
|
45
|
+
- lib/capistrano-helpers/features.rb
|
46
|
+
- lib/capistrano-helpers/gems.rb
|
47
|
+
- lib/capistrano-helpers/git.rb
|
48
|
+
- lib/capistrano-helpers/migrations.rb
|
49
|
+
- lib/capistrano-helpers/passenger.rb
|
50
|
+
- lib/capistrano-helpers/php.rb
|
51
|
+
- lib/capistrano-helpers/preflight.rb
|
52
|
+
- lib/capistrano-helpers/privates.rb
|
53
|
+
- lib/capistrano-helpers/shared.rb
|
54
|
+
- lib/capistrano-helpers/specs.rb
|
55
|
+
- lib/capistrano-helpers/version.rb
|
56
|
+
- test/capistrano-helpers_test.rb
|
57
|
+
- test/test_helper.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/westarete/capistrano-helpers
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --charset=UTF-8
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: A set of optional extensions to capistrano to make common tasks easier.
|
86
|
+
test_files:
|
87
|
+
- test/capistrano-helpers_test.rb
|
88
|
+
- test/test_helper.rb
|