capistrano-bundle_rsync 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +11 -0
- data/README.md +10 -5
- data/capistrano-bundle_rsync.gemspec +1 -1
- data/example/Capfile +12 -0
- data/example/Gemfile +7 -0
- data/example/config/deploy/local_git.rb +4 -0
- data/example/config/deploy/sample.rb +5 -0
- data/example/config/deploy.rb +28 -0
- data/lib/capistrano/bundle_rsync/base.rb +14 -0
- data/lib/capistrano/bundle_rsync/bundler.rb +59 -0
- data/lib/capistrano/bundle_rsync/config.rb +11 -3
- data/lib/capistrano/bundle_rsync/git.rb +43 -0
- data/lib/capistrano/bundle_rsync/local_git.rb +42 -0
- data/lib/capistrano/bundle_rsync/scm.rb +80 -0
- data/lib/capistrano/bundle_rsync.rb +0 -1
- data/lib/capistrano/tasks/bundle_rsync.rake +22 -79
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57fd444228ffd2aaa2b08ae8a3aa48d641709f98
|
4
|
+
data.tar.gz: 04086f39219dc6ff6922e4a09596907b105a8a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76e50e567ac213341bafb10e0dc0060a6fe6aba2bb4c5ed46e4c8fd3e9b5f50b34227083d245abcb59f673f1788c4330f21d0c3c01000703b3100a2970c93641
|
7
|
+
data.tar.gz: d4ffdd544a4d85f5b558940bef818000e3edb1cdc98106976340c9003eb099f59f1ae5428b911357472a636598c560853da5d47e3727eac50e184e98ab8baa9e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 0.2.0 (2014/07/11)
|
2
|
+
|
3
|
+
Enhancements:
|
4
|
+
|
5
|
+
* Support `bundle_rsync_keep_releases` configuration
|
6
|
+
* Newly add `set :bundle_rsync_scm 'local_git'` configuration
|
7
|
+
|
8
|
+
Changes:
|
9
|
+
|
10
|
+
* Rename `bundle_rsync_local_repo_path` to `bundle_rsync_local_mirror_path`
|
11
|
+
|
1
12
|
# 0.1.1 (2014/07/09)
|
2
13
|
|
3
14
|
Enhancements:
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Also saves you from having to install Git and Build Tools on your production mac
|
|
12
12
|
|
13
13
|
Capistrano::BundleRsync works as followings:
|
14
14
|
|
15
|
-
1. Do `git clone --mirror URL .local_repo/
|
15
|
+
1. Do `git clone --mirror URL .local_repo/mirror` on a deploy (local) machine.
|
16
16
|
2. Extract a branch by `git archive {branch}` to `.local_repo/release_{time}`
|
17
17
|
4. Deploy the `release` directory to remote machines by `rsync`.
|
18
18
|
3. Do `bundle --without development,test --path .local_repo/bundle` on a deploy (local) machine.
|
@@ -48,16 +48,21 @@ Name | Default | Description
|
|
48
48
|
repo_url | `.` | The path or URL to a Git repository to clone from.
|
49
49
|
branch | `master` | The Git branch to checkout.
|
50
50
|
ssh_options | `{}` | Configuration of ssh :user and :keys.
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
keep\_releases | 5 | The number of releases to keep.
|
52
|
+
scm | nil | Must be `bundle_rsync` to use capistrano-bundle_rsync.
|
53
|
+
bundle_rsync_local_base_path | `$(pwd)/.local_repo` | The base directory to clone repository
|
54
|
+
bundle_rsync_local_mirror_path | `#{base_path}/mirror"` | Path where to mirror your repository
|
55
|
+
bundle_rsync_local_releases_path | `"#{base_path}/releases"` | Path of the directory to checkout your repository
|
56
|
+
bundle_rsync_local_release_path | `"#{release_dir}/#{time}"` | Path to checkout your repository (releases_path + release_name)
|
54
57
|
bundle_rsync_local_bundle_path | `"#{base_path}/bundle"` | Path where to bundle install gems.
|
55
58
|
bundle_rsync_local_bin_path | `"#{base_path}/bin"` | Path where to bundle install bin scripts.
|
56
59
|
bundle_rsync_config_files | `nil` | Additional files to rsync. Specified files are copied into `config` directory.
|
57
60
|
bundle_rsync_ssh_options | `ssh_options` | Configuration of ssh for rsync. Default uses the value of `ssh_options`
|
61
|
+
bundle_rsync_keep_releases | `keep_releases` | The number of releases to keep on .local_repo
|
58
62
|
bundle_rsync_max_parallels | number of hosts | Number of concurrency. The default is the number of hosts to deploy.
|
59
63
|
bundle_rsync_rsync_bwlimit | nil | Configuration of rsync --bwlimit (KBPS) option. Not Avabile if `bundle_rsync_rsync_options` is specified.
|
60
64
|
bundle_rsync_rsync_options | `-az --delete` | Configuration of rsync options.
|
65
|
+
bundle_rsync_scm | 'git' or 'local_git' | SCM Strategy inside `bundle_rsync`. `git` uses git. `local_git` also uses git, but it enables to rsync the git repository located on local path directly without git clone. `repo_url` must be the local directory path to use `local_git`.
|
61
66
|
|
62
67
|
## Installation
|
63
68
|
|
@@ -162,7 +167,7 @@ A. capistrano-bundle\_rsync does `bundle install` at the deploy machine, not on
|
|
162
167
|
|
163
168
|
## ToDo
|
164
169
|
|
165
|
-
|
170
|
+
1. Support other SCMs than `git`.
|
166
171
|
|
167
172
|
## ChangeLog
|
168
173
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "capistrano-bundle_rsync"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.authors = ["sonots", "tohae"]
|
9
9
|
spec.email = ["sonots@gmail.com", "tohaechan@gmail.com"]
|
10
10
|
spec.description = %q{Deploy an application and bundled gems via rsync}
|
data/example/Capfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Load DSL and Setup Up Stages
|
2
|
+
require 'capistrano/setup'
|
3
|
+
|
4
|
+
# Includes default deployment tasks
|
5
|
+
require 'capistrano/deploy'
|
6
|
+
|
7
|
+
# Includes tasks from other gems included in your Gemfile
|
8
|
+
require 'capistrano/rbenv'
|
9
|
+
require 'capistrano/bundle_rsync'
|
10
|
+
|
11
|
+
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
12
|
+
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
data/example/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# config valid only for Capistrano 3.2.1
|
2
|
+
lock '3.2.1'
|
3
|
+
|
4
|
+
set :user, 'game'
|
5
|
+
set :ssh_options, user: ENV['USER'], keys: [File.expand_path('~/.ssh/id_rsa')]
|
6
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
7
|
+
|
8
|
+
set :linked_dirs, %w(bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system tmp/run)
|
9
|
+
set :keep_releases, 5
|
10
|
+
set :rbenv_type, :user
|
11
|
+
set :rbenv_ruby, '2.1.2'
|
12
|
+
set :deploy_to, "#{ENV['HOME']}/sample"
|
13
|
+
|
14
|
+
set :scm, :bundle_rsync
|
15
|
+
set :bundle_rsync_max_parallels, ENV['PARA']
|
16
|
+
set :bundle_rsync_rsync_bwlimit, ENV['BWLIMIT'] # like 20000
|
17
|
+
|
18
|
+
namespace :deploy do
|
19
|
+
desc 'Restart web application'
|
20
|
+
task :restart do
|
21
|
+
on roles(:web), in: :sequence, wait: 5 do
|
22
|
+
# execute some restart code
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
after :finishing, 'deploy:cleanup'
|
27
|
+
# after :publishing, :restart
|
28
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'capistrano/bundle_rsync/base'
|
2
|
+
|
3
|
+
class Capistrano::BundleRsync::Bundler < Capistrano::BundleRsync::Base
|
4
|
+
def prepare
|
5
|
+
hosts = release_roles(:all)
|
6
|
+
on hosts, in: :groups, limit: config.max_parallels(hosts) do
|
7
|
+
within release_path do
|
8
|
+
execute :mkdir, '-p', '.bundle'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def install
|
14
|
+
hosts = release_roles(:all)
|
15
|
+
Bundler.with_clean_env do
|
16
|
+
execute :bundle, "--gemfile #{config.local_release_path}/Gemfile --deployment --quiet --path #{config.local_bundle_path} --without development test --binstubs=#{config.local_bin_path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
lines = <<-EOS
|
20
|
+
---
|
21
|
+
BUNDLE_FROZEN: '1'
|
22
|
+
BUNDLE_PATH: #{shared_path.join('bundle')}
|
23
|
+
BUNDLE_WITHOUT: development:test
|
24
|
+
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
25
|
+
BUNDLE_BIN: #{shared_path.join('bin')}
|
26
|
+
EOS
|
27
|
+
bundle_config_path = "#{config.local_base_path}/bundle_config"
|
28
|
+
File.open(bundle_config_path, "w") {|file| file.print(lines) }
|
29
|
+
|
30
|
+
rsync_options = config.rsync_options
|
31
|
+
Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
|
32
|
+
ssh = config.build_ssh_command(host)
|
33
|
+
if config_files = config.config_files
|
34
|
+
config_files.each do |config_file|
|
35
|
+
basename = File.basename(config_file)
|
36
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config_file} #{host}:#{release_path}/config/#{basename}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bundle_path}/ #{host}:#{shared_path}/bundle/"
|
41
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bin_path}/ #{host}:#{shared_path}/bin/"
|
42
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{bundle_config_path} #{host}:#{release_path}/.bundle/config"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Do not remove if :bundle_rsync_local_release_path is directly specified.
|
46
|
+
unless fetch(:bundle_rsync_local_release_path)
|
47
|
+
releases = capture(:ls, '-x', config.local_releases_path).split
|
48
|
+
if releases.count >= config.keep_releases
|
49
|
+
directories = (releases - releases.last(config.keep_releases))
|
50
|
+
if directories.any?
|
51
|
+
directories_str = directories.map do |release|
|
52
|
+
releases_path.join(release)
|
53
|
+
end.join(" ")
|
54
|
+
execute :rm, '-rf', directories_str
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -4,12 +4,16 @@ module Capistrano::BundleRsync
|
|
4
4
|
@local_base_path ||= fetch(:bundle_rsync_local_base_path) || "#{Dir::pwd}/.local_repo"
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.
|
8
|
-
@
|
7
|
+
def self.local_mirror_path
|
8
|
+
@local_mirror_path ||= fetch(:bundle_rsync_local_mirror_path) || "#{local_base_path}/mirror"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.local_releases_path
|
12
|
+
@local_releases_path ||= fetch(:bundle_rsync_local_releases_path) || "#{local_base_path}/releases"
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.local_release_path
|
12
|
-
@local_release_path ||= fetch(:bundle_rsync_local_release_path) || "#{
|
16
|
+
@local_release_path ||= fetch(:bundle_rsync_local_release_path) || "#{local_releases_path}/#{Time.new.strftime('%Y%m%d%H%M%S')}"
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.local_bundle_path
|
@@ -69,6 +73,10 @@ module Capistrano::BundleRsync
|
|
69
73
|
"ssh#{user_opt}#{key_opt}#{port_opt}"
|
70
74
|
end
|
71
75
|
|
76
|
+
def self.keep_releases
|
77
|
+
@keep_releases = fetch(:bundle_rsync_keep_releases) || fetch(:keep_releases)
|
78
|
+
end
|
79
|
+
|
72
80
|
# Fetch the :bundle_rsync_max_parallels,
|
73
81
|
# where the default is the number of hosts
|
74
82
|
def self.max_parallels(hosts)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'capistrano/bundle_rsync/scm'
|
2
|
+
|
3
|
+
class Capistrano::BundleRsync::Git < Capistrano::BundleRsync::SCM
|
4
|
+
def check
|
5
|
+
exit 1 unless execute("git ls-remote #{repo_url}")
|
6
|
+
execute("mkdir -p #{config.local_base_path}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def clone
|
10
|
+
if File.exist?("#{config.local_mirror_path}/HEAD")
|
11
|
+
info t(:mirror_exists, at: config.local_mirror_path)
|
12
|
+
else
|
13
|
+
execute :git, :clone, '--mirror', repo_url, config.local_mirror_path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def update
|
18
|
+
within config.local_mirror_path do
|
19
|
+
execute :git, :remote, :update
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_release
|
24
|
+
hosts = release_roles(:all)
|
25
|
+
execute "mkdir -p #{config.local_release_path}"
|
26
|
+
|
27
|
+
within config.local_mirror_path do
|
28
|
+
execute :git, :archive, fetch(:branch), '| tar -x -C', "#{config.local_release_path}"
|
29
|
+
end
|
30
|
+
|
31
|
+
rsync_options = config.rsync_options
|
32
|
+
Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
|
33
|
+
ssh = config.build_ssh_command(host)
|
34
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_release_path}/ #{host}:#{release_path}/"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_current_revision
|
39
|
+
within config.local_mirror_path do
|
40
|
+
set :current_revision, capture(:git, "rev-parse --short #{fetch(:branch)}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'capistrano/bundle_rsync/scm'
|
2
|
+
|
3
|
+
class Capistrano::BundleRsync::LocalGit < Capistrano::BundleRsync::SCM
|
4
|
+
def check
|
5
|
+
raise ArgumentError.new('`repo_url` must be local path to use `local_git` scm') unless local_path?(repo_url)
|
6
|
+
exit 1 unless execute("git ls-remote #{repo_url}")
|
7
|
+
execute("mkdir -p #{config.local_base_path}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def clone
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_release
|
17
|
+
hosts = release_roles(:all)
|
18
|
+
rsync_options = config.rsync_options
|
19
|
+
Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
|
20
|
+
ssh = config.build_ssh_command(host)
|
21
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{repo_url}/ #{host}:#{release_path}/"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_current_revision
|
26
|
+
within repo_url do
|
27
|
+
set :current_revision, capture(:git, "rev-parse --short HEAD")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def local_path?(repo_url)
|
34
|
+
return !(
|
35
|
+
repo_url.start_with?('http://') or
|
36
|
+
repo_url.start_with?('https://') or
|
37
|
+
repo_url.start_with?('git://') or
|
38
|
+
repo_url.start_with?('git@') or
|
39
|
+
repo_url.start_with?('ssh://')
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'capistrano/bundle_rsync/base'
|
2
|
+
|
3
|
+
# Base class for SCM strategy providers.
|
4
|
+
#
|
5
|
+
# @abstract
|
6
|
+
class Capistrano::BundleRsync::SCM < Capistrano::BundleRsync::Base
|
7
|
+
# @abstract
|
8
|
+
#
|
9
|
+
# Your implementation should check the existence of a cache repository on
|
10
|
+
# the deployment target
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
13
|
+
#
|
14
|
+
def test
|
15
|
+
raise NotImplementedError.new(
|
16
|
+
"Your SCM strategy module should provide a #test method"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @abstract
|
21
|
+
#
|
22
|
+
# Your implementation should check if the specified remote-repository is
|
23
|
+
# available.
|
24
|
+
#
|
25
|
+
# @return [Boolean]
|
26
|
+
#
|
27
|
+
def check
|
28
|
+
raise NotImplementedError.new(
|
29
|
+
"Your SCM strategy module should provide a #check method"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @abstract
|
34
|
+
#
|
35
|
+
# Create a (new) clone of the remote-repository on the deployment target
|
36
|
+
#
|
37
|
+
# @return void
|
38
|
+
#
|
39
|
+
def clone
|
40
|
+
raise NotImplementedError.new(
|
41
|
+
"Your SCM strategy module should provide a #clone method"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
# @abstract
|
46
|
+
#
|
47
|
+
# Update the clone on the deployment target
|
48
|
+
#
|
49
|
+
# @return void
|
50
|
+
#
|
51
|
+
def update
|
52
|
+
raise NotImplementedError.new(
|
53
|
+
"Your SCM strategy module should provide a #update method"
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @abstract
|
58
|
+
#
|
59
|
+
# Copy the contents of the cache-repository onto the release path
|
60
|
+
#
|
61
|
+
# @return void
|
62
|
+
#
|
63
|
+
def create_release
|
64
|
+
raise NotImplementedError.new(
|
65
|
+
"Your SCM strategy module should provide a #create_release method"
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @abstract
|
70
|
+
#
|
71
|
+
# Identify the SHA of the commit that will be deployed. This will most likely involve SshKit's capture method.
|
72
|
+
#
|
73
|
+
# @return void
|
74
|
+
#
|
75
|
+
def set_current_revision
|
76
|
+
raise NotImplementedError.new(
|
77
|
+
"Your SCM strategy module should provide a #set_current_revision method"
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
@@ -2,126 +2,69 @@ unless defined?(Capistrano::BundleRsync::TASK_LOADED) # protect multiple loads
|
|
2
2
|
Capistrano::BundleRsync::TASK_LOADED = true
|
3
3
|
require 'fileutils'
|
4
4
|
require 'parallel'
|
5
|
+
require 'capistrano/bundle_rsync/bundler'
|
5
6
|
|
6
7
|
namespace :bundle_rsync do
|
7
|
-
def
|
8
|
-
Capistrano::BundleRsync::
|
8
|
+
def bundler
|
9
|
+
@bundler ||= Capistrano::BundleRsync::Bundler.new(self)
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def scm
|
13
|
+
@scm ||=
|
14
|
+
if fetch(:bundle_rsync_scm) == 'local_git'
|
15
|
+
require 'capistrano/bundle_rsync/local_git'
|
16
|
+
set :bundle_rsync_local_release_path, repo_url
|
17
|
+
Capistrano::BundleRsync::LocalGit.new(self)
|
18
|
+
else
|
19
|
+
require 'capistrano/bundle_rsync/git'
|
20
|
+
Capistrano::BundleRsync::Git.new(self)
|
18
21
|
end
|
22
|
+
end
|
19
23
|
|
24
|
+
namespace :bundler do
|
25
|
+
task :install do
|
26
|
+
bundler.prepare
|
20
27
|
run_locally do
|
21
|
-
|
22
|
-
execute :bundle, "--gemfile #{config.local_release_path}/Gemfile --deployment --quiet --path #{config.local_bundle_path} --without development test --binstubs=#{config.local_bin_path}"
|
23
|
-
end
|
24
|
-
|
25
|
-
lines = <<-EOS
|
26
|
-
---
|
27
|
-
BUNDLE_FROZEN: '1'
|
28
|
-
BUNDLE_PATH: #{shared_path.join('bundle')}
|
29
|
-
BUNDLE_WITHOUT: development:test
|
30
|
-
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
31
|
-
BUNDLE_BIN: #{shared_path.join('bin')}
|
32
|
-
EOS
|
33
|
-
bundle_config_path = "#{config.local_base_path}/bundle_config"
|
34
|
-
File.open(bundle_config_path, "w") {|file| file.print(lines) }
|
35
|
-
|
36
|
-
rsync_options = config.rsync_options
|
37
|
-
Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
|
38
|
-
ssh = config.build_ssh_command(host)
|
39
|
-
if config_files = config.config_files
|
40
|
-
config_files.each do |config_file|
|
41
|
-
basename = File.basename(config_file)
|
42
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config_file} #{host}:#{release_path}/config/#{basename}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bundle_path}/ #{host}:#{shared_path}/bundle/"
|
47
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bin_path}/ #{host}:#{shared_path}/bin/"
|
48
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{bundle_config_path} #{host}:#{release_path}/.bundle/config"
|
49
|
-
end
|
50
|
-
|
51
|
-
FileUtils.rm_rf(config.local_release_path)
|
28
|
+
bundler.install
|
52
29
|
end
|
53
30
|
end
|
54
31
|
end
|
55
32
|
|
56
33
|
desc 'Check that the repository is reachable'
|
57
34
|
task :check do
|
58
|
-
fetch(:branch)
|
59
35
|
run_locally do
|
60
|
-
|
61
|
-
execute("mkdir -p #{config.local_base_path}")
|
36
|
+
scm.check
|
62
37
|
end
|
63
38
|
end
|
64
39
|
|
65
40
|
desc 'Clone the repo to the cache'
|
66
41
|
task :clone do
|
67
42
|
run_locally do
|
68
|
-
|
69
|
-
info t(:mirror_exists, at: config.local_repo_path)
|
70
|
-
else
|
71
|
-
execute :git, :clone, '--mirror', repo_url, config.local_repo_path
|
72
|
-
end
|
43
|
+
scm.clone
|
73
44
|
end
|
74
45
|
end
|
75
46
|
|
76
47
|
desc 'Update the repo mirror to reflect the origin state'
|
77
48
|
task update: :'bundle_rsync:clone' do
|
78
49
|
run_locally do
|
79
|
-
|
80
|
-
execute :git, :remote, :update
|
81
|
-
end
|
50
|
+
scm.update
|
82
51
|
end
|
83
52
|
end
|
84
53
|
|
85
54
|
desc 'Copy repo to releases'
|
86
55
|
task create_release: :'bundle_rsync:update' do
|
87
|
-
hosts = roles(:all)
|
88
56
|
run_locally do
|
89
|
-
|
90
|
-
|
91
|
-
within config.local_repo_path do
|
92
|
-
execute :git, :archive, fetch(:branch), '| tar -x -C', "#{config.local_release_path}"
|
93
|
-
end
|
94
|
-
|
95
|
-
rsync_options = config.rsync_options
|
96
|
-
Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
|
97
|
-
ssh = config.build_ssh_command(host)
|
98
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_release_path}/ #{host}:#{release_path}/"
|
99
|
-
end
|
57
|
+
scm.create_release
|
100
58
|
end
|
101
59
|
end
|
102
60
|
|
103
61
|
desc 'Determine the revision that will be deployed'
|
104
62
|
task :set_current_revision do
|
105
63
|
run_locally do
|
106
|
-
|
107
|
-
set :current_revision, capture(:git, "rev-parse --short #{fetch(:branch)}")
|
108
|
-
end
|
64
|
+
scm.set_current_revision
|
109
65
|
end
|
110
66
|
end
|
111
67
|
|
112
68
|
before 'deploy:updated', 'bundle_rsync:bundler:install'
|
113
69
|
end
|
114
|
-
|
115
|
-
namespace :load do
|
116
|
-
task :defaults do
|
117
|
-
set :bundle_rsync_local_base_path, nil
|
118
|
-
set :bundle_rsync_local_repo_path, nil
|
119
|
-
set :bundle_rsync_local_release_path, nil
|
120
|
-
set :bundle_rsync_local_bundle_path, nil
|
121
|
-
set :bundle_rsync_local_bin_path, nil
|
122
|
-
set :bundle_rsync_config_files, nil
|
123
|
-
set :bundle_rsync_ssh_options, nil # Default to be ssh_options. Note: :password is not supported.
|
124
|
-
set :bundle_rsync_max_parallels, nil
|
125
|
-
end
|
126
|
-
end
|
127
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-bundle_rsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonots
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -82,9 +82,19 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- capistrano-bundle_rsync.gemspec
|
85
|
+
- example/Capfile
|
86
|
+
- example/Gemfile
|
87
|
+
- example/config/deploy.rb
|
88
|
+
- example/config/deploy/local_git.rb
|
89
|
+
- example/config/deploy/sample.rb
|
85
90
|
- lib/capistrano-bundle_rsync.rb
|
86
91
|
- lib/capistrano/bundle_rsync.rb
|
92
|
+
- lib/capistrano/bundle_rsync/base.rb
|
93
|
+
- lib/capistrano/bundle_rsync/bundler.rb
|
87
94
|
- lib/capistrano/bundle_rsync/config.rb
|
95
|
+
- lib/capistrano/bundle_rsync/git.rb
|
96
|
+
- lib/capistrano/bundle_rsync/local_git.rb
|
97
|
+
- lib/capistrano/bundle_rsync/scm.rb
|
88
98
|
- lib/capistrano/tasks/bundle_rsync.rake
|
89
99
|
homepage: https://github.com/sonots/capistrano-bundle_rsync
|
90
100
|
licenses:
|