php-composer-deploy 0.0.2
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.
- checksums.yaml +7 -0
- data/CHANGELOG.markdown +5 -0
- data/LICENSE.markdown +22 -0
- data/README.markdown +50 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/lib/php-composer-deploy.rb +461 -0
- data/php-composer-deploy.gemspec +33 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89b054b675077756d12f7f00c5eedd611e59eeb8
|
4
|
+
data.tar.gz: 582eefa333e1f2b61cf2ffa62bd1fb4c2ed024fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e596052edc9deab0bd40285ccd02dadc0beff6972a4b91c76de9fce5fd5c576b9d9a916dd814d6d2a1b97f59847c8f3adc0681e844b1828971cc1513dce95f7
|
7
|
+
data.tar.gz: 84d0c6a828f817392cc3bc772e9a82d51f4c8c82f2ccebc8485699183e38c3ab5e4569ae3c07645074d0c28662edd11db46f9dd0f2d7088b314d79b68cea1af0
|
data/CHANGELOG.markdown
ADDED
data/LICENSE.markdown
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) <2013> Joseph Lombardo <me@joseph-lombardo.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
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
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# PHP Composer Deploy
|
2
|
+
|
3
|
+
If you want to use Capistrano to deploy php apps using Composer, this is it.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
# gem install php-composer-deploy
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Open your application's `Capfile` and make it begins like this:
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'php-composer-deploy'
|
15
|
+
load 'config/deploy'
|
16
|
+
|
17
|
+
Remove `require 'deploy'` since we are overriding that
|
18
|
+
|
19
|
+
Full list of tasks:
|
20
|
+
|
21
|
+
$ cap -T
|
22
|
+
|
23
|
+
## What do you get?
|
24
|
+
|
25
|
+
If you want to try before you buy, here's the list of tasks included with this version of the deploy recipe:
|
26
|
+
|
27
|
+
cap deploy # Deploys your project.
|
28
|
+
cap deploy:check # Test deployment dependencies.
|
29
|
+
cap deploy:cleanup # Clean up old releases.
|
30
|
+
cap deploy:cold # Deploys and starts a `cold' application.
|
31
|
+
cap deploy:pending # Displays the commits since your last deploy.
|
32
|
+
cap deploy:pending:diff # Displays the `diff' since your last deploy.
|
33
|
+
cap deploy:rollback # Rolls back to a previous version and restarts.
|
34
|
+
cap deploy:rollback:code # Rolls back to the previously deployed version.
|
35
|
+
cap deploy:setup # Prepares one or more servers for deployment.
|
36
|
+
cap deploy:create_symlink # Updates the symlink to the most recently deployed ...
|
37
|
+
cap deploy:update # Copies your project and updates the symlink.
|
38
|
+
cap deploy:update_code # Copies your project to the remote servers.
|
39
|
+
cap deploy:upload # Copy files to the currently deployed version.
|
40
|
+
cap composer:install # Run composer install in the currently symlinked directory
|
41
|
+
cap composer:copy_vendors # Copy the vendors folder from the previously deployed version
|
42
|
+
cap invoke # Invoke a single command on the remote servers.
|
43
|
+
cap shell # Begin an interactive Capistrano session.
|
44
|
+
|
45
|
+
|
46
|
+
## Want to help improve this?
|
47
|
+
|
48
|
+
Fork me on GitHub:
|
49
|
+
|
50
|
+
http://github.com/lombardoja/php-composer-deploy
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "php-composer-deploy"
|
5
|
+
gemspec.summary = "Replacement for the default Capistrano tasks, designed to make life easier for PHP devs using composer"
|
6
|
+
gemspec.description = "Replacement for the rails deploy strategy which ships with Capistrano, allows you to deploy any platform with ease; some people have had huge success with this deploying rails projects where they needed to customise their deploy strategy beyond the code which ships with the Capistrano gem."
|
7
|
+
gemspec.email = "me@joseph-lombardo.com"
|
8
|
+
gemspec.homepage = "http://github.com/lombardoja/php-composer-deploy/"
|
9
|
+
gemspec.authors = ["Joseph Lombardo"]
|
10
|
+
end
|
11
|
+
rescue LoadError
|
12
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
13
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,461 @@
|
|
1
|
+
# Most of this is borrowed from https://github.com/leehambley/railsless-deploy and heavily modified. Kudos to them.
|
2
|
+
# Thanks for doing all the heavy lifting!
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
|
5
|
+
require 'capistrano/recipes/deploy/scm'
|
6
|
+
require 'capistrano/recipes/deploy/strategy'
|
7
|
+
|
8
|
+
def _cset(name, *args, &block)
|
9
|
+
unless exists?(name)
|
10
|
+
set(name, *args, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# =========================================================================
|
15
|
+
# These variables MUST be set in the client capfiles. If they are not set,
|
16
|
+
# the deploy will fail with an error.
|
17
|
+
# =========================================================================
|
18
|
+
|
19
|
+
_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
|
20
|
+
_cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
|
21
|
+
|
22
|
+
# =========================================================================
|
23
|
+
# These variables may be set in the client capfile if their default values
|
24
|
+
# are not sufficient.
|
25
|
+
# =========================================================================
|
26
|
+
|
27
|
+
_cset :scm, :subversion
|
28
|
+
_cset :deploy_via, :checkout
|
29
|
+
|
30
|
+
_cset(:deploy_to) { "/u/apps/#{application}" }
|
31
|
+
_cset(:revision) { source.head }
|
32
|
+
|
33
|
+
# =========================================================================
|
34
|
+
# These variables should NOT be changed unless you are very confident in
|
35
|
+
# what you are doing. Make sure you understand all the implications of your
|
36
|
+
# changes if you do decide to muck with these!
|
37
|
+
# =========================================================================
|
38
|
+
|
39
|
+
_cset(:source) { Capistrano::Deploy::SCM.new(scm, self) }
|
40
|
+
_cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }
|
41
|
+
|
42
|
+
_cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
|
43
|
+
|
44
|
+
_cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
|
45
|
+
|
46
|
+
_cset :version_dir, "releases"
|
47
|
+
_cset :shared_dir, "shared"
|
48
|
+
_cset :shared_children, [] # Empty!
|
49
|
+
_cset :current_dir, "current"
|
50
|
+
|
51
|
+
_cset(:releases_path) { File.join(deploy_to, version_dir) }
|
52
|
+
_cset(:shared_path) { File.join(deploy_to, shared_dir) }
|
53
|
+
_cset(:current_path) { File.join(deploy_to, current_dir) }
|
54
|
+
_cset(:release_path) { File.join(releases_path, release_name) }
|
55
|
+
|
56
|
+
_cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }
|
57
|
+
_cset(:current_release) { releases.any? ? File.join(releases_path, releases.last) : nil }
|
58
|
+
_cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
|
59
|
+
|
60
|
+
_cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
|
61
|
+
_cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
|
62
|
+
_cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
|
63
|
+
|
64
|
+
_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
|
65
|
+
|
66
|
+
# some tasks, like create_symlink, need to always point at the latest release, but
|
67
|
+
# they can also (occassionally) be called standalone. In the standalone case,
|
68
|
+
# the timestamped release_path will be inaccurate, since the directory won't
|
69
|
+
# actually exist. This variable lets tasks like create_symlink work either in the
|
70
|
+
# standalone case, or during deployment.
|
71
|
+
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
|
72
|
+
|
73
|
+
# =========================================================================
|
74
|
+
# These are helper methods that will be available to your recipes.
|
75
|
+
# =========================================================================
|
76
|
+
|
77
|
+
# Auxiliary helper method for the `deploy:check' task. Lets you set up your
|
78
|
+
# own dependencies.
|
79
|
+
def depend(location, type, *args)
|
80
|
+
deps = fetch(:dependencies, {})
|
81
|
+
deps[location] ||= {}
|
82
|
+
deps[location][type] ||= []
|
83
|
+
deps[location][type] << args
|
84
|
+
set :dependencies, deps
|
85
|
+
end
|
86
|
+
|
87
|
+
# Temporarily sets an environment variable, yields to a block, and restores
|
88
|
+
# the value when it is done.
|
89
|
+
def with_env(name, value)
|
90
|
+
saved, ENV[name] = ENV[name], value
|
91
|
+
yield
|
92
|
+
ensure
|
93
|
+
ENV[name] = saved
|
94
|
+
end
|
95
|
+
|
96
|
+
# logs the command then executes it locally.
|
97
|
+
# returns the command output as a string
|
98
|
+
def run_locally(cmd)
|
99
|
+
logger.trace "executing locally: #{cmd.inspect}" if logger
|
100
|
+
`#{cmd}`
|
101
|
+
end
|
102
|
+
|
103
|
+
# If a command is given, this will try to execute the given command, as
|
104
|
+
# described below. Otherwise, it will return a string for use in embedding in
|
105
|
+
# another command, for executing that command as described below.
|
106
|
+
#
|
107
|
+
# If :run_method is :sudo (or :use_sudo is true), this executes the given command
|
108
|
+
# via +sudo+. Otherwise is uses +run+. If :as is given as a key, it will be
|
109
|
+
# passed as the user to sudo as, if using sudo. If the :as key is not given,
|
110
|
+
# it will default to whatever the value of the :admin_runner variable is,
|
111
|
+
# which (by default) is unset.
|
112
|
+
#
|
113
|
+
# THUS, if you want to try to run something via sudo, and what to use the
|
114
|
+
# root user, you'd just to try_sudo('something'). If you wanted to try_sudo as
|
115
|
+
# someone else, you'd just do try_sudo('something', :as => "bob"). If you
|
116
|
+
# always wanted sudo to run as a particular user, you could do
|
117
|
+
# set(:admin_runner, "bob").
|
118
|
+
def try_sudo(*args)
|
119
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
120
|
+
command = args.shift
|
121
|
+
raise ArgumentError, "too many arguments" if args.any?
|
122
|
+
|
123
|
+
as = options.fetch(:as, fetch(:admin_runner, nil))
|
124
|
+
via = fetch(:run_method, :sudo)
|
125
|
+
if command
|
126
|
+
invoke_command(command, :via => via, :as => as)
|
127
|
+
elsif via == :sudo
|
128
|
+
sudo(:as => as)
|
129
|
+
else
|
130
|
+
""
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Same as sudo, but tries sudo with :as set to the value of the :runner
|
135
|
+
# variable (which defaults to "app").
|
136
|
+
def try_runner(*args)
|
137
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
138
|
+
args << options.merge(:as => fetch(:runner, "app"))
|
139
|
+
try_sudo(*args)
|
140
|
+
end
|
141
|
+
|
142
|
+
# =========================================================================
|
143
|
+
# These are the tasks that are available to help with deploying web apps,
|
144
|
+
# and specifically, Rails applications. You can have cap give you a summary
|
145
|
+
# of them with `cap -T'.
|
146
|
+
# =========================================================================
|
147
|
+
|
148
|
+
namespace :deploy do
|
149
|
+
desc <<-DESC
|
150
|
+
Deploys your project. Handy wrapper to hook into the beginning of the deployment. Note that \
|
151
|
+
this will generally only work for applications that have already been deployed \
|
152
|
+
once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \
|
153
|
+
task, which handles the cold start specifically.
|
154
|
+
DESC
|
155
|
+
task :default do
|
156
|
+
update
|
157
|
+
end
|
158
|
+
|
159
|
+
desc <<-DESC
|
160
|
+
Prepares one or more servers for deployment. Before you can use any \
|
161
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
162
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
163
|
+
you add a new server to your cluster, you can easily run the setup task \
|
164
|
+
on just that server by specifying the HOSTS environment variable:
|
165
|
+
|
166
|
+
$ cap HOSTS=new.server.com deploy:setup
|
167
|
+
|
168
|
+
It is safe to run this task on servers that have already been set up; it \
|
169
|
+
will not destroy any deployed revisions or data.
|
170
|
+
DESC
|
171
|
+
task :setup, :except => { :no_release => true } do
|
172
|
+
dirs = [deploy_to, releases_path, shared_path]
|
173
|
+
dirs += shared_children.map { |d| File.join(shared_path, d.split('/').last) }
|
174
|
+
run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
|
175
|
+
end
|
176
|
+
|
177
|
+
desc <<-DESC
|
178
|
+
Copies your project and updates the symlink. It does this in a \
|
179
|
+
transaction, so that if either `update_code' or `create_symlink' fail, all \
|
180
|
+
changes made to the remote servers will be rolled back, leaving your \
|
181
|
+
system in the same state it was in before `update' was invoked. Usually, \
|
182
|
+
you will want to call `deploy' instead of `update', but `update' can be \
|
183
|
+
handy if you want to deploy, but not immediately restart your application.
|
184
|
+
DESC
|
185
|
+
task :update do
|
186
|
+
transaction do
|
187
|
+
update_code
|
188
|
+
create_symlink
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
desc <<-DESC
|
193
|
+
Copies your project to the remote servers. This is the first stage \
|
194
|
+
of any deployment; moving your updated code and assets to the deployment \
|
195
|
+
servers. You will rarely call this task directly, however; instead, you \
|
196
|
+
should call the `deploy' task (to do a complete deploy) or the `update' \
|
197
|
+
task (if you want to perform the `restart' task separately).
|
198
|
+
|
199
|
+
You will need to make sure you set the :scm variable to the source \
|
200
|
+
control software you are using (it defaults to :subversion), and the \
|
201
|
+
:deploy_via variable to the strategy you want to use to deploy (it \
|
202
|
+
defaults to :checkout).
|
203
|
+
DESC
|
204
|
+
task :update_code, :except => { :no_release => true } do
|
205
|
+
on_rollback { run "rm -rf #{release_path}; true" }
|
206
|
+
strategy.deploy!
|
207
|
+
finalize_update
|
208
|
+
end
|
209
|
+
|
210
|
+
desc <<-DESC
|
211
|
+
[internal] Touches up the released code. This is called by update_code \
|
212
|
+
after the basic deploy finishes. It assumes a Rails project was deployed, \
|
213
|
+
so if you are deploying something else, you may want to override this \
|
214
|
+
task with your own environment's requirements.
|
215
|
+
|
216
|
+
This task will make the release group-writable (if the :group_writable \
|
217
|
+
variable is set to true, which is the default). It will then set up \
|
218
|
+
symlinks to the shared directory for the log, system, and tmp/pids \
|
219
|
+
directories, and will lastly touch all assets in public/images, \
|
220
|
+
public/stylesheets, and public/javascripts so that the times are \
|
221
|
+
consistent (so that asset timestamping works). This touch process \
|
222
|
+
is only carried out if the :normalize_asset_timestamps variable is \
|
223
|
+
set to true, which is the default.
|
224
|
+
DESC
|
225
|
+
task :finalize_update, :except => { :no_release => true } do
|
226
|
+
# mkdir -p is making sure that the directories are there for some SCM's that don't
|
227
|
+
# save empty folders
|
228
|
+
shared_children.map do |d|
|
229
|
+
if (d.rindex('/')) then
|
230
|
+
run "rm -rf #{latest_release}/#{d} && mkdir -p #{latest_release}/#{d.slice(0..(d.rindex('/')))}"
|
231
|
+
else
|
232
|
+
run "rm -rf #{latest_release}/#{d}"
|
233
|
+
end
|
234
|
+
run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}"
|
235
|
+
end
|
236
|
+
|
237
|
+
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
|
238
|
+
|
239
|
+
shared_children.map do |d|
|
240
|
+
run <<-CMD
|
241
|
+
rm -rf #{latest_release}/#{d} &&
|
242
|
+
ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}
|
243
|
+
CMD
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
desc <<-DESC
|
248
|
+
Updates the symlink to the most recently deployed version. Capistrano works \
|
249
|
+
by putting each new release of your application in its own directory. When \
|
250
|
+
you deploy a new version, this task's job is to update the `current' symlink \
|
251
|
+
to point at the new version. You will rarely need to call this task \
|
252
|
+
directly; instead, use the `deploy' task (which performs a complete \
|
253
|
+
deploy, including `restart') or the 'update' task (which does everything \
|
254
|
+
except `restart').
|
255
|
+
DESC
|
256
|
+
task :create_symlink, :except => { :no_release => true } do
|
257
|
+
on_rollback do
|
258
|
+
if previous_release
|
259
|
+
run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
|
260
|
+
else
|
261
|
+
logger.important "no previous release to rollback to, rollback of symlink skipped"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
|
266
|
+
end
|
267
|
+
|
268
|
+
desc <<-DESC
|
269
|
+
Deprecated. Use `deploy:create_symlink` instead.
|
270
|
+
DESC
|
271
|
+
task :symlink, :except => { :no_release => true } do
|
272
|
+
warn "[Deprecation Warning] This API has changed, please use `deploy:create_symlink` instead of" \
|
273
|
+
" `deploy:symlink`."
|
274
|
+
|
275
|
+
create_symlink
|
276
|
+
end
|
277
|
+
|
278
|
+
desc <<-DESC
|
279
|
+
Copy files to the currently deployed version. This is useful for updating \
|
280
|
+
files piecemeal, such as when you need to quickly deploy only a single \
|
281
|
+
file. Some files, such as updated templates, images, or stylesheets, \
|
282
|
+
might not require a full deploy, and especially in emergency situations \
|
283
|
+
it can be handy to just push the updates to production, quickly.
|
284
|
+
|
285
|
+
To use this task, specify the files and directories you want to copy as a \
|
286
|
+
comma-delimited list in the FILES environment variable. All directories \
|
287
|
+
will be processed recursively, with all files being pushed to the \
|
288
|
+
deployment servers.
|
289
|
+
|
290
|
+
$ cap deploy:upload FILES=templates,controller.rb
|
291
|
+
|
292
|
+
Dir globs are also supported:
|
293
|
+
|
294
|
+
$ cap deploy:upload FILES='config/apache/*.conf'
|
295
|
+
DESC
|
296
|
+
task :upload, :except => { :no_release => true } do
|
297
|
+
files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
|
298
|
+
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
|
299
|
+
|
300
|
+
files.each { |file| top.upload(file, File.join(current_path, file)) }
|
301
|
+
end
|
302
|
+
|
303
|
+
namespace :rollback do
|
304
|
+
desc <<-DESC
|
305
|
+
[internal] Points the current symlink at the previous revision.
|
306
|
+
This is called by the rollback sequence, and should rarely (if
|
307
|
+
ever) need to be called directly.
|
308
|
+
DESC
|
309
|
+
task :revision, :except => { :no_release => true } do
|
310
|
+
if previous_release
|
311
|
+
run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
|
312
|
+
else
|
313
|
+
abort "could not rollback the code because there is no prior release"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
desc <<-DESC
|
318
|
+
[internal] Removes the most recently deployed release.
|
319
|
+
This is called by the rollback sequence, and should rarely
|
320
|
+
(if ever) need to be called directly.
|
321
|
+
DESC
|
322
|
+
task :cleanup, :except => { :no_release => true } do
|
323
|
+
run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
|
324
|
+
end
|
325
|
+
|
326
|
+
desc <<-DESC
|
327
|
+
Rolls back to the previously deployed version. The `current' symlink will \
|
328
|
+
be updated to point at the previously deployed version, and then the \
|
329
|
+
current release will be removed from the servers.
|
330
|
+
DESC
|
331
|
+
task :code, :except => { :no_release => true } do
|
332
|
+
revision
|
333
|
+
cleanup
|
334
|
+
end
|
335
|
+
|
336
|
+
desc <<-DESC
|
337
|
+
Rolls back to a previous version and restarts. This is handy if you ever \
|
338
|
+
discover that you've deployed a lemon; `cap rollback' and you're right \
|
339
|
+
back where you were, on the previously deployed version.
|
340
|
+
DESC
|
341
|
+
task :default do
|
342
|
+
revision
|
343
|
+
cleanup
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
desc <<-DESC
|
348
|
+
Clean up old releases. By default, the last 5 releases are kept on each \
|
349
|
+
server (though you can change this with the keep_releases variable). All \
|
350
|
+
other deployed revisions are removed from the servers. By default, this \
|
351
|
+
will use sudo to clean up the old releases, but if sudo is not available \
|
352
|
+
for your environment, set the :use_sudo variable to false instead.
|
353
|
+
DESC
|
354
|
+
task :cleanup, :except => { :no_release => true } do
|
355
|
+
count = fetch(:keep_releases, 5).to_i
|
356
|
+
if count >= releases.length
|
357
|
+
logger.important "no old releases to clean up"
|
358
|
+
else
|
359
|
+
logger.info "keeping #{count} of #{releases.length} deployed releases"
|
360
|
+
|
361
|
+
directories = (releases - releases.last(count)).map { |release|
|
362
|
+
File.join(releases_path, release) }.join(" ")
|
363
|
+
|
364
|
+
try_sudo "rm -rf #{directories}"
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
desc <<-DESC
|
369
|
+
Test deployment dependencies. Checks things like directory permissions, \
|
370
|
+
necessary utilities, and so forth, reporting on the things that appear to \
|
371
|
+
be incorrect or missing. This is good for making sure a deploy has a \
|
372
|
+
chance of working before you actually run `cap deploy'.
|
373
|
+
|
374
|
+
You can define your own dependencies, as well, using the `depend' method:
|
375
|
+
|
376
|
+
depend :remote, :gem, "tzinfo", ">=0.3.3"
|
377
|
+
depend :local, :command, "svn"
|
378
|
+
depend :remote, :directory, "/u/depot/files"
|
379
|
+
DESC
|
380
|
+
task :check, :except => { :no_release => true } do
|
381
|
+
dependencies = strategy.check!
|
382
|
+
|
383
|
+
other = fetch(:dependencies, {})
|
384
|
+
other.each do |location, types|
|
385
|
+
types.each do |type, calls|
|
386
|
+
if type == :gem
|
387
|
+
dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command")
|
388
|
+
end
|
389
|
+
|
390
|
+
calls.each do |args|
|
391
|
+
dependencies.send(location).send(type, *args)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
if dependencies.pass?
|
397
|
+
puts "You appear to have all necessary dependencies installed"
|
398
|
+
else
|
399
|
+
puts "The following dependencies failed. Please check them and try again:"
|
400
|
+
dependencies.reject { |d| d.pass? }.each do |d|
|
401
|
+
puts "--> #{d.message}"
|
402
|
+
end
|
403
|
+
abort
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
desc <<-DESC
|
408
|
+
Deploys and starts a `cold' application. This is useful if you have not \
|
409
|
+
deployed your application before, or if your application is (for some \
|
410
|
+
other reason) not currently running. It will deploy the code, run any \
|
411
|
+
pending migrations, and then instead of invoking `deploy:restart', it will \
|
412
|
+
invoke `deploy:start' to fire up the application servers.
|
413
|
+
DESC
|
414
|
+
task :cold do
|
415
|
+
update
|
416
|
+
end
|
417
|
+
|
418
|
+
namespace :pending do
|
419
|
+
desc <<-DESC
|
420
|
+
Displays the `diff' since your last deploy. This is useful if you want \
|
421
|
+
to examine what changes are about to be deployed. Note that this might \
|
422
|
+
not be supported on all SCM's.
|
423
|
+
DESC
|
424
|
+
task :diff, :except => { :no_release => true } do
|
425
|
+
system(source.local.diff(current_revision))
|
426
|
+
end
|
427
|
+
|
428
|
+
desc <<-DESC
|
429
|
+
Displays the commits since your last deploy. This is good for a summary \
|
430
|
+
of the changes that have occurred since the last deploy. Note that this \
|
431
|
+
might not be supported on all SCM's.
|
432
|
+
DESC
|
433
|
+
task :default, :except => { :no_release => true } do
|
434
|
+
from = source.next_revision(current_revision)
|
435
|
+
system(source.local.log(from))
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
namespace :composer do
|
442
|
+
desc <<-DESC
|
443
|
+
Manages composer dependencies in your project.
|
444
|
+
DESC
|
445
|
+
task :default do
|
446
|
+
install
|
447
|
+
end
|
448
|
+
|
449
|
+
desc "Copy vendors from previous release"
|
450
|
+
task :copy_vendors, :except => { :no_release => true } do
|
451
|
+
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
|
452
|
+
end
|
453
|
+
desc "Install vendors in current path"
|
454
|
+
task :install do
|
455
|
+
run "sh -c 'cd #{latest_release} && curl -s http://getcomposer.org/installer | php'"
|
456
|
+
run "sh -c 'cd #{release_path} && ./composer.phar install'"
|
457
|
+
end
|
458
|
+
|
459
|
+
end
|
460
|
+
|
461
|
+
end # Capistrano::Configuration.instance(:must_exist).load do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "php-composer-deploy"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Joseph Lombardo"]
|
12
|
+
s.date = "2013-07-25"
|
13
|
+
s.description = "Replacement for the rails deploy strategy which ships with Capistrano, allows you to deploy any platform with ease; some people have had huge success with this deploying rails projects where they needed to customise their deploy strategy beyond the code which ships with the Capistrano gem."
|
14
|
+
s.email = "me@joseph-lombardo.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.markdown",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"CHANGELOG.markdown",
|
21
|
+
"LICENSE.markdown",
|
22
|
+
"README.markdown",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/php-composer-deploy.rb",
|
26
|
+
"php-composer-deploy.gemspec"
|
27
|
+
]
|
28
|
+
s.homepage = "http://github.com/lombardoja/php-composer-deploy/"
|
29
|
+
s.require_paths = ["lib"]
|
30
|
+
s.rubygems_version = "2.0.3"
|
31
|
+
s.summary = "Replacement for the default Capistrano tasks, designed to make life easier for PHP devs using composer"
|
32
|
+
end
|
33
|
+
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: php-composer-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Lombardo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Replacement for the rails deploy strategy which ships with Capistrano,
|
14
|
+
allows you to deploy any platform with ease; some people have had huge success with
|
15
|
+
this deploying rails projects where they needed to customise their deploy strategy
|
16
|
+
beyond the code which ships with the Capistrano gem.
|
17
|
+
email: me@joseph-lombardo.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files:
|
21
|
+
- LICENSE.markdown
|
22
|
+
- README.markdown
|
23
|
+
files:
|
24
|
+
- CHANGELOG.markdown
|
25
|
+
- LICENSE.markdown
|
26
|
+
- README.markdown
|
27
|
+
- Rakefile
|
28
|
+
- VERSION
|
29
|
+
- lib/php-composer-deploy.rb
|
30
|
+
- php-composer-deploy.gemspec
|
31
|
+
homepage: http://github.com/lombardoja/php-composer-deploy/
|
32
|
+
licenses: []
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.0.3
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Replacement for the default Capistrano tasks, designed to make life easier
|
54
|
+
for PHP devs using composer
|
55
|
+
test_files: []
|