capistrano-helpers 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -5,6 +5,12 @@ Fixed:
5
5
  * Campfire notifications were broken. Updated for new API, use git names for announcements.
6
6
  * Force a chown of vendor/bundler, since building gems sometimes doesn't preserve group permissions.
7
7
  Hopefully there will be a fix for this someday so we can avoid this workaround.
8
+ * Only require tinder gem when using campfire helper, to reduce size of installation.
9
+
10
+ Added:
11
+
12
+ * Growl notification helper
13
+ * Ding notifier
8
14
 
9
15
  ## 0.5.7
10
16
 
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = capistrano-helpers
2
2
 
3
- A set of optional extensions to capistrano to make common tasks easier and
3
+ A set of optional extensions to capistrano to make common tasks easier and
4
4
  reduce redundancy across your deployments.
5
5
 
6
6
  == Usage
@@ -42,14 +42,22 @@ Automatically runs "bundle install --deployment" to install gems from your Gemfi
42
42
 
43
43
  === campfire
44
44
 
45
- After the application has been deployed, this helper will post a message to
46
- the given campfire room stating the username, the application, the branch/tag,
47
- and the environment. E.g.:
45
+ Once the deploy is complete, this helper will post a message to the given
46
+ Campfire room stating the username, the application, the branch/tag and the
47
+ environment. E.g.:
48
48
 
49
- Scott Woods just deployed myapp v0.5.4 to staging
49
+ Scott Woods finished deploying myapp v0.5.4 to staging
50
50
 
51
- This helper expects to find a configuration file config/campfire.yml or ~/.campfire.yml
52
- with the following format:
51
+ By default, it will only post when the deploy is complete. If you'd also
52
+ like it to post when the deploy begins, you can add the following line
53
+ to your deploy script:
54
+
55
+ before "deploy", "deploy:post_to_campfire_before"
56
+
57
+ You will need to install the tinder gem to enable campfire notifications. Run
58
+ <tt>sudo gem install tinder</tt>, or add <tt>gem 'tinder'</tt> to your Gemfile.
59
+ This helper expects to find a configuration file config/campfire.yml or
60
+ ~/.campfire.yml with the following format:
53
61
 
54
62
  # Configuration for posting to campfire.
55
63
  subdomain: mycompany
@@ -60,23 +68,42 @@ You can override the location of the configuration file by setting the
60
68
  :campfire_config variable:
61
69
 
62
70
  set :campfire_config, 'somewhere/else.yml'
63
-
71
+
72
+ You can disable the notification for a specific deployment stage by setting
73
+ the :campfire_notifications variable to false.
74
+ E.g. in config/deploy/staging:
75
+
76
+ set :campfire_notifications, false
77
+
78
+ === ding
79
+
80
+ Once the deploy is complete, this helper will play a 'ding' sound (Mac only).
81
+
64
82
  === features
65
83
 
66
84
  Before the app is deployed, this helper checks out the branch/tag that is
67
85
  being deployed and runs all the cucumber features, ensuring that they all
68
86
  pass.
69
87
 
70
- == gems
88
+ === gems
71
89
 
72
90
  Run the gems:install rake task using sudo after deployment.
73
91
 
74
- == git
92
+ === git
75
93
 
76
94
  Set git as the repository type, and set up remote caching to speed up
77
95
  deployments.
78
96
 
79
- == migrations
97
+ === growl
98
+
99
+ Once the deploy is complete, this helper will post a message to Growl stating
100
+ the application, the branch/tag and the environment. E.g.:
101
+
102
+ capistrano
103
+
104
+ finished deploying myapp v0.5.4 to staging
105
+
106
+ === migrations
80
107
 
81
108
  Always run migrations during deployment.
82
109
 
@@ -144,7 +171,7 @@ and this helper insures they exist. Remember to run this *after* the rest of you
144
171
 
145
172
  This works much like the shared helper above, except the symbolic link will
146
173
  point to the same path under "shared/private" on the server. This allows you
147
- to set special permissions on that directory for keeping particularly
174
+ to set special permissions on that directory for keeping particularly
148
175
  sensitive files safe, such as those that contain passwords or encryption keys.
149
176
 
150
177
  After requiring this helper, set the paths to be symlinked using the
@@ -154,7 +181,7 @@ After requiring this helper, set the paths to be symlinked using the
154
181
  config/database.yml
155
182
  config/session_secret.txt
156
183
  }
157
-
184
+
158
185
  This will create two symbolic links on the production server:
159
186
 
160
187
  #{release_path}/config/database.yml -> #{shared_path}/private/config/database.yml
@@ -165,6 +192,11 @@ This will create two symbolic links on the production server:
165
192
  Before the app is deployed, this helper checks out the branch/tag that is
166
193
  being deployed and runs all the rspec specs, ensuring that they all pass.
167
194
 
195
+ === unicorn
196
+
197
+ Overrides the default :restart task so that it's compatible with restarting
198
+ unicorn.
199
+
168
200
  === version
169
201
 
170
202
  Creates a VERSION file in the deployed copy that contains the name of the
data/Rakefile CHANGED
@@ -9,10 +9,9 @@ begin
9
9
  gem.description = %Q{A set of optional extensions to capistrano to make common tasks easier.}
10
10
  gem.email = "team@westarete.com"
11
11
  gem.homepage = "http://github.com/westarete/capistrano-helpers"
12
- gem.authors = ["Scott Woods", "Clinton Judy"]
13
- gem.add_dependency('capistrano')
12
+ gem.authors = ["Scott Woods"]
13
+ gem.add_dependency('capistrano', '~> 2.0')
14
14
  gem.add_dependency('git')
15
- gem.add_dependency('tinder')
16
15
  end
17
16
 
18
17
  rescue LoadError
@@ -41,7 +40,7 @@ end
41
40
 
42
41
  task :default => :test
43
42
 
44
- require 'rake/rdoctask'
43
+ require 'rdoc/task'
45
44
  Rake::RDocTask.new do |rdoc|
46
45
  if File.exist?('VERSION.yml')
47
46
  config = YAML.load(File.read('VERSION.yml'))
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{capistrano-helpers}
8
- s.version = "0.7.1"
7
+ s.name = "capistrano-helpers"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Scott Woods", "Clinton Judy"]
12
- s.date = %q{2012-04-16}
13
- s.description = %q{A set of optional extensions to capistrano to make common tasks easier.}
14
- s.email = %q{team@westarete.com}
11
+ s.authors = ["Scott Woods"]
12
+ s.date = "2013-11-06"
13
+ s.description = "A set of optional extensions to capistrano to make common tasks easier."
14
+ s.email = "team@westarete.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -39,31 +39,28 @@ Gem::Specification.new do |s|
39
39
  "lib/capistrano-helpers/shared.rb",
40
40
  "lib/capistrano-helpers/skylinecms.rb",
41
41
  "lib/capistrano-helpers/specs.rb",
42
+ "lib/capistrano-helpers/unicorn.rb",
42
43
  "lib/capistrano-helpers/version.rb",
43
44
  "test/test_helper.rb"
44
45
  ]
45
- s.homepage = %q{http://github.com/westarete/capistrano-helpers}
46
+ s.homepage = "http://github.com/westarete/capistrano-helpers"
46
47
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
48
- s.summary = %q{A set of optional extensions to capistrano to make common tasks easier.}
48
+ s.rubygems_version = "1.8.24"
49
+ s.summary = "A set of optional extensions to capistrano to make common tasks easier."
49
50
 
50
51
  if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
52
  s.specification_version = 3
53
53
 
54
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<capistrano>, [">= 0"])
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<capistrano>, ["~> 2.0"])
56
56
  s.add_runtime_dependency(%q<git>, [">= 0"])
57
- s.add_runtime_dependency(%q<tinder>, [">= 0"])
58
57
  else
59
- s.add_dependency(%q<capistrano>, [">= 0"])
58
+ s.add_dependency(%q<capistrano>, ["~> 2.0"])
60
59
  s.add_dependency(%q<git>, [">= 0"])
61
- s.add_dependency(%q<tinder>, [">= 0"])
62
60
  end
63
61
  else
64
- s.add_dependency(%q<capistrano>, [">= 0"])
62
+ s.add_dependency(%q<capistrano>, ["~> 2.0"])
65
63
  s.add_dependency(%q<git>, [">= 0"])
66
- s.add_dependency(%q<tinder>, [">= 0"])
67
64
  end
68
65
  end
69
66
 
@@ -1,34 +1,44 @@
1
1
  require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
2
2
 
3
- require 'tinder'
3
+ begin
4
+ require 'tinder'
5
+ rescue LoadError
6
+ raise RuntimeError, "tinder gem required for Campfire deploy notifications. Run `sudo gem install tinder`, or add `gem 'tinder'` to your Gemfile."
7
+ end
8
+
4
9
  require 'git'
5
10
 
6
11
  CapistranoHelpers.with_configuration do
7
12
 
8
13
  namespace :deploy do
9
- desc 'Make a post to campfire to tell everyone about this deployment.'
14
+ desc "Post to campfire that this deployment is complete"
15
+ task :post_to_campfire_after do
16
+ post_to_campfire(:after)
17
+ end
18
+
19
+ desc "Post to campfire that this deployment has begun"
10
20
  task :post_to_campfire_before do
11
- config_file = [fetch(:campfire_config, 'config/campfire.yml'), "#{ENV['HOME']}/.campfire.yml"].detect { |f| File.readable?(f) }
12
- if config_file.nil?
13
- puts "Could not find a campfire configuration. Skipping campfire notification."
21
+ post_to_campfire(:before)
22
+ end
23
+
24
+ def post_to_campfire(hook=:before)
25
+ case hook
26
+ when :before
27
+ action = 'started deploying'
28
+ when :after
29
+ action = 'finished deploying'
14
30
  else
15
- if ! exists?(:application)
16
- puts "You should set :application to the name of this app."
17
- end
18
- git_config = Git.open('.').config rescue {}
19
- someone = ENV['GIT_AUTHOR_NAME'] || git_config['user.name'] || `whoami`.strip
20
- target = fetch(:stage, 'production')
21
- config = YAML::load_file(config_file)
22
- campfire = Tinder::Campfire.new(config['subdomain'], :token => config['token'])
23
- room = campfire.find_room_by_name(config['room'])
24
- room.speak("#{someone} started deploying #{application} #{branch} to #{target}")
31
+ return
25
32
  end
26
- end
27
33
 
28
- task :post_to_campfire_after do
34
+ # If the :branch reference is a full SHA1, display it in its abbreviated form
35
+ campfire_branch = fetch(:branch).sub(/\b([a-f0-9]{7})[a-f0-9]{33}\b/, '\1')
36
+
29
37
  config_file = [fetch(:campfire_config, 'config/campfire.yml'), "#{ENV['HOME']}/.campfire.yml"].detect { |f| File.readable?(f) }
30
38
  if config_file.nil?
31
- puts "Could not find a campfire configuration. Skipping campfire notification."
39
+ puts "Could not find a campfire configuration. Skipping campfire notification."
40
+ elsif fetch(:campfire_notifications, true) == false
41
+ # Campfire notifications are disabled, nothing to do
32
42
  else
33
43
  if ! exists?(:application)
34
44
  puts "You should set :application to the name of this app."
@@ -39,11 +49,11 @@ CapistranoHelpers.with_configuration do
39
49
  config = YAML::load_file(config_file)
40
50
  campfire = Tinder::Campfire.new(config['subdomain'], :token => config['token'])
41
51
  room = campfire.find_room_by_name(config['room'])
42
- room.speak("#{someone} finished deploying #{application} #{branch} to #{target}")
52
+ room.speak("#{someone} #{action} #{application} #{campfire_branch} to #{target}")
43
53
  end
44
54
  end
45
55
  end
56
+
46
57
  after "deploy:restart", "deploy:post_to_campfire_after"
47
- before "deploy", "deploy:post_to_campfire_before"
48
58
 
49
59
  end
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
2
2
 
3
3
  CapistranoHelpers.with_configuration do
4
-
4
+
5
5
  namespace :deploy do
6
6
  desc 'Replace named files with a symlink to their counterparts in shared/private/'
7
7
  task :symlink_privates do
@@ -15,8 +15,17 @@ CapistranoHelpers.with_configuration do
15
15
  run "rm -rf #{release_path}/#{path} && ln -nfs #{shared_path}/private/#{path} #{release_path}/#{path}"
16
16
  end
17
17
  end
18
+
19
+ desc '[internal] Create a private directory in shared'
20
+ task :create_private_dir do
21
+ private_dir = 'private'
22
+ private_path = File.join(shared_path, private_dir)
23
+ run "#{try_sudo} mkdir -p #{private_path}"
24
+ run "#{try_sudo} chmod o-rwx #{private_path}"
25
+ end
18
26
  end
19
27
 
20
28
  before "deploy:finalize_update", "deploy:symlink_privates"
29
+ after "deploy:setup", "deploy:create_private_dir"
21
30
 
22
- end
31
+ end
@@ -6,7 +6,7 @@ CapistranoHelpers.with_configuration do
6
6
  namespace :deploy do
7
7
  desc "Make sure all specs pass"
8
8
  task :check_specs do
9
- if scm != 'git'
9
+ if scm.to_sym != :git
10
10
  abort "Sorry, you can only check specs if you're using git as your scm."
11
11
  end
12
12
  `git branch` =~ /^\* ([^\s]+)/ or abort "Couldn't understand the output of `git branch`."
@@ -30,4 +30,4 @@ CapistranoHelpers.with_configuration do
30
30
 
31
31
  before "deploy:update_code", "deploy:check_specs"
32
32
 
33
- end
33
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../capistrano-helpers' if ! defined?(CapistranoHelpers)
2
+
3
+ CapistranoHelpers.with_configuration do
4
+
5
+ namespace :unicorn do
6
+ desc "Restart unicorn"
7
+ task :restart, :roles => :web, :except => { :no_release => true } do
8
+ run "oldpid=$(cat /var/www/#{application}/#{stage}/shared/pids/unicorn.pid) && kill -s USR2 $oldpid && echo 'Searching for newly spawned master process...' && until (pid=$(cat /var/www/#{application}/#{stage}/shared/pids/unicorn.pid 2>/dev/null) && test '$pid' != '$oldpid' && ps x |grep $pid|grep master) ; do sleep 1 ; done && kill -s WINCH $oldpid && kill -s QUIT $oldpid"
9
+ end
10
+ end
11
+ after "deploy:restart", "unicorn:restart"
12
+
13
+ end
metadata CHANGED
@@ -1,69 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capistrano-helpers
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 7
8
- - 1
9
- version: 0.7.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.2
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Scott Woods
13
- - Clinton Judy
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-05-09 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-11-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: capistrano
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
31
22
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: git
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: git
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
43
38
  type: :runtime
44
- version_requirements: *id002
45
- - !ruby/object:Gem::Dependency
46
- name: tinder
47
39
  prerelease: false
48
- requirement: &id003 !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
- version: "0"
55
- type: :runtime
56
- version_requirements: *id003
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
57
46
  description: A set of optional extensions to capistrano to make common tasks easier.
58
47
  email: team@westarete.com
59
48
  executables: []
60
-
61
49
  extensions: []
62
-
63
- extra_rdoc_files:
50
+ extra_rdoc_files:
64
51
  - LICENSE
65
52
  - README.rdoc
66
- files:
53
+ files:
67
54
  - .document
68
55
  - CHANGELOG.markdown
69
56
  - LICENSE
@@ -86,37 +73,32 @@ files:
86
73
  - lib/capistrano-helpers/shared.rb
87
74
  - lib/capistrano-helpers/skylinecms.rb
88
75
  - lib/capistrano-helpers/specs.rb
76
+ - lib/capistrano-helpers/unicorn.rb
89
77
  - lib/capistrano-helpers/version.rb
90
78
  - test/test_helper.rb
91
- has_rdoc: true
92
79
  homepage: http://github.com/westarete/capistrano-helpers
93
80
  licenses: []
94
-
95
81
  post_install_message:
96
82
  rdoc_options: []
97
-
98
- require_paths:
83
+ require_paths:
99
84
  - lib
100
- required_ruby_version: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- segments:
105
- - 0
106
- version: "0"
107
- required_rubygems_version: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
- version: "0"
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
114
97
  requirements: []
115
-
116
98
  rubyforge_project:
117
- rubygems_version: 1.3.6
99
+ rubygems_version: 1.8.25
118
100
  signing_key:
119
101
  specification_version: 3
120
102
  summary: A set of optional extensions to capistrano to make common tasks easier.
121
103
  test_files: []
122
-
104
+ has_rdoc: