capistrano-rsync-git 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +20 -0
- data/README.md +71 -0
- data/capistrano-rsync-git.gemspec +30 -0
- data/lib/capistrano/rsync.rb +82 -0
- data/lib/capistrano/rsync/version.rb +13 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1a8d392c5a86b490144923501cecf989cc1efa7e
|
4
|
+
data.tar.gz: c7ebc0227d9d355faaae64821d19545cd9f2e91a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b2290ed1daecac6316eab9afbb7aa6e65e3ed399f5d3c8127799423a6737b2014929f977108f42875c85815e77ed634b367f69ab9832003adf3f981765cd27d
|
7
|
+
data.tar.gz: d9cb881d735bbde08bb6540285cb57e186e79006d5df758dd9cdf1ec8bf5e8b6afeaa2e1ec97d9b2529bb8b8bf369551320e39b83fcb1a9883ca982d88c2f1b4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
capistrano-rsync-git (0.1.2)
|
5
|
+
capistrano (>= 3.4, < 4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
capistrano (3.4.0)
|
11
|
+
i18n
|
12
|
+
rake (>= 10.0.0)
|
13
|
+
sshkit (~> 1.3)
|
14
|
+
colorize (0.7.7)
|
15
|
+
i18n (0.7.0)
|
16
|
+
net-scp (1.2.1)
|
17
|
+
net-ssh (>= 2.6.5)
|
18
|
+
net-ssh (3.0.1)
|
19
|
+
rake (10.4.2)
|
20
|
+
sshkit (1.7.1)
|
21
|
+
colorize (>= 0.7.0)
|
22
|
+
net-scp (>= 1.1.2)
|
23
|
+
net-ssh (>= 2.8.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
capistrano-rsync-git!
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011, 2012, 2013, 2014, 2015, Jake Gordon and contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
20
|
+
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Capistrano 3 deploy with Rsync & Git
|
2
|
+
|
3
|
+
Deploy with Rsync to your server from a local Git repository when using Capistrano. Saves
|
4
|
+
you from having to install Git on your production machine and allows you to customize which
|
5
|
+
files you want to deploy.
|
6
|
+
|
7
|
+
>> **NOTE**: This library has a Mercurial flavored version at [jakesgordon/capistrano-rsync-hg](https://github.com/jakesgordon/capistrano-rsync-hg)
|
8
|
+
|
9
|
+
## Using
|
10
|
+
|
11
|
+
Install with:
|
12
|
+
|
13
|
+
gem install capistrano-rsync-git # or add to your Gemfile
|
14
|
+
|
15
|
+
Require it at the top of your Capfile
|
16
|
+
|
17
|
+
require "capistrano/rsync"
|
18
|
+
|
19
|
+
Tell capistrano to use our Rsync SCM strategy within `deploy.rb`
|
20
|
+
|
21
|
+
set :scm, :rsync
|
22
|
+
|
23
|
+
And add other related options to your liking:
|
24
|
+
|
25
|
+
set :user, "deploy"
|
26
|
+
set :repo_url, "ssh://git@github.com/myusername/myrepository"
|
27
|
+
set :branch, "default"
|
28
|
+
set :rsync_exclude, %w[ .git* ]
|
29
|
+
set :rsync_include, %w[ ]
|
30
|
+
set :rsync_options, %w[ --archive --recursive --delete --delete-excluded ]
|
31
|
+
set :local_cache, ".cache_#{fetch(:stage)}"
|
32
|
+
set :remote_cache, "shared/cache"
|
33
|
+
|
34
|
+
* `:user` - the user used in the rsync connection (optional).
|
35
|
+
* `:repo_url` - the repository to clone.
|
36
|
+
* `:branch` - the branch to checkout.
|
37
|
+
* `:rsync_exclude` - array of files/paths to exclude from rsync (optional).
|
38
|
+
* `:rsync_include` - array of files/paths to override subset of `:rsync_exclude` (optional).
|
39
|
+
* `:rsync_options` - additional rsync options (optional).
|
40
|
+
* `:local_cache` - the local cache folder (where the repo will be checked out) - either absolute or relative to the local project root.
|
41
|
+
* `:remote_cache` - the remote cache folder (where the files will be rsynced to) - either absolute or relative to capistrano `deploy_to` variable.
|
42
|
+
|
43
|
+
And after setting regular Capistrano options, deploy as usual:
|
44
|
+
|
45
|
+
cap production deploy
|
46
|
+
|
47
|
+
## Implementation
|
48
|
+
|
49
|
+
1. Clones and updates your repository to `local_cache` on your local machine.
|
50
|
+
2. Checks out the branch set in the branch variable.
|
51
|
+
3. Rsyncs to the `remote_cache` directory on the server.
|
52
|
+
4. Copies the content of the `remote_cache` directory to a new release directory.
|
53
|
+
|
54
|
+
After that, Capistrano takes over and runs its usual tasks and symlinking.
|
55
|
+
|
56
|
+
## Exclude files from being deployed
|
57
|
+
|
58
|
+
If you don't want to deploy everything you've committed to your repository, specify `:rsync_exclude`
|
59
|
+
|
60
|
+
set :rsync_exclude, %w[
|
61
|
+
.git*
|
62
|
+
/config/database.yml
|
63
|
+
/test/***
|
64
|
+
]
|
65
|
+
|
66
|
+
## Other tasks
|
67
|
+
|
68
|
+
cap rsync:stage # checkout the repo/branch into the :local_cache
|
69
|
+
cap rsync:sync # ... and sync to the server(s)
|
70
|
+
cap rsync:release # ... and copy to a release folder (but WITHOUT symlinking the current directory)
|
71
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require_relative 'lib/capistrano/rsync/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.name = Capistrano::Rsync::NAME
|
8
|
+
s.version = Capistrano::Rsync::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = Capistrano::Rsync::AUTHORS
|
11
|
+
s.email = Capistrano::Rsync::EMAIL
|
12
|
+
s.homepage = Capistrano::Rsync::HOMEPAGE
|
13
|
+
s.summary = Capistrano::Rsync::SUMMARY
|
14
|
+
s.description = Capistrano::Rsync::DESCRIPTION
|
15
|
+
s.license = Capistrano::Rsync::LICENSE
|
16
|
+
|
17
|
+
s.has_rdoc = false
|
18
|
+
s.extra_rdoc_files = ["README.md"]
|
19
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
20
|
+
s.files = `git ls-files `.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
s.required_ruby_version = '~> 2.1'
|
26
|
+
|
27
|
+
s.add_runtime_dependency 'capistrano', '>= 3.4', '< 4'
|
28
|
+
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
remote_cache = lambda do
|
3
|
+
cache = fetch(:remote_cache)
|
4
|
+
cache = deploy_to + "/" + cache if cache && cache !~ /^\//
|
5
|
+
cache
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :load do
|
9
|
+
task :defaults do
|
10
|
+
set :rsync_exclude, %w[.git*]
|
11
|
+
set :rsync_include, %w[ ]
|
12
|
+
set :rsync_options, %w[--archive --recursive --delete --delete-excluded]
|
13
|
+
set :copy_command, "rsync --archive --acls --xattrs"
|
14
|
+
set :local_cache, ".rsync_#{fetch(:stage)}"
|
15
|
+
set :remote_cache, "shared/rsync"
|
16
|
+
set :repo_url, File.expand_path(".")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace "rsync" do
|
21
|
+
|
22
|
+
task :check do
|
23
|
+
# nothing to check, but expected by framework
|
24
|
+
end
|
25
|
+
|
26
|
+
task :create_cache do
|
27
|
+
next if File.directory?(File.expand_path(fetch(:local_cache))) # TODO: check if it's actually our repo instead of assuming
|
28
|
+
run_locally do
|
29
|
+
execute :git, 'clone', fetch(:repo_url), fetch(:local_cache)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "stage the repository in a local directory"
|
34
|
+
task :stage => [ :create_cache ] do
|
35
|
+
run_locally do
|
36
|
+
within fetch(:local_cache) do
|
37
|
+
execute :git, "fetch", "--quiet", "--all", "--prune"
|
38
|
+
execute :git, "reset", "--hard", "origin/#{fetch(:branch)}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "stage and rsync to the server"
|
44
|
+
task :sync => [ :stage ] do
|
45
|
+
release_roles(:all).each do |role|
|
46
|
+
|
47
|
+
user = role.user || fetch(:user)
|
48
|
+
user = user + "@" unless user.nil?
|
49
|
+
|
50
|
+
rsync_args = []
|
51
|
+
rsync_args.concat fetch(:rsync_options)
|
52
|
+
rsync_args.concat fetch(:rsync_include, []).map{|e| "--include #{e}"}
|
53
|
+
rsync_args.concat fetch(:rsync_exclude, []).map{|e| "--exclude #{e}"}
|
54
|
+
rsync_args << fetch(:local_cache) + "/"
|
55
|
+
rsync_args << "#{user}#{role.hostname}:#{remote_cache.call}"
|
56
|
+
|
57
|
+
run_locally do
|
58
|
+
execute :rsync, *rsync_args
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "stage, rsync to the server, and copy the code to the releases directory"
|
64
|
+
task :release => [ :sync ] do
|
65
|
+
copy = %(#{fetch(:copy_command)} "#{remote_cache.call}/" "#{release_path}/")
|
66
|
+
on release_roles(:all) do
|
67
|
+
execute copy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
task :create_release => [ :release ] do
|
72
|
+
# expected by the framework, delegate to better named task
|
73
|
+
end
|
74
|
+
|
75
|
+
task :set_current_revision do
|
76
|
+
run_locally do
|
77
|
+
set :current_revision, capture(:git, 'rev-parse', fetch(:branch))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Rsync
|
3
|
+
NAME = "capistrano-rsync-git"
|
4
|
+
VERSION = "0.1.2"
|
5
|
+
AUTHORS = [ "Jake Gordon" ]
|
6
|
+
EMAIL = "jake@codeincomplete.com"
|
7
|
+
HOMEPAGE = "https://github.com/jakesgordon/capistrano-rsync-git"
|
8
|
+
SUMMARY = "Capistrano v3 deploy with rsync from a local Git repository"
|
9
|
+
DESCRIPTION = "Capistrano v3 deploy with rsync from a local Git repository without requiring SCM access on the server"
|
10
|
+
LICENSE = "MIT"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-rsync-git
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Gordon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.4'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4'
|
33
|
+
description: Capistrano v3 deploy with rsync from a local Git repository without requiring
|
34
|
+
SCM access on the server
|
35
|
+
email: jake@codeincomplete.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files:
|
39
|
+
- README.md
|
40
|
+
files:
|
41
|
+
- ".gitignore"
|
42
|
+
- Gemfile
|
43
|
+
- Gemfile.lock
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- capistrano-rsync-git.gemspec
|
47
|
+
- lib/capistrano/rsync.rb
|
48
|
+
- lib/capistrano/rsync/version.rb
|
49
|
+
homepage: https://github.com/jakesgordon/capistrano-rsync-git
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options:
|
55
|
+
- "--charset=UTF-8"
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.1'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.4.5.1
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Capistrano v3 deploy with rsync from a local Git repository
|
74
|
+
test_files: []
|