capistrano-rsync-hg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 98116d4c3164f9c06c1c0170d0a4039f17558cc9
4
+ data.tar.gz: e25783909362254ecdee268508318947647b3333
5
+ SHA512:
6
+ metadata.gz: 9b28685f0b81bbf5255e4828e060dcea25c66c16cbfd3e3b691969ef66db043ecdc789174391cc11be3bf4fc53878e687facd3bdc87e5b10a5f83e78a0be197e
7
+ data.tar.gz: a25da7440a5f45ce185b6ca83401209581708ef0c6f37431113ce17bb44224e90e3197ad2feb09565e1039f61468a8a2e4feb4e34eaf1425038898eabb40024c
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *~
2
+ *.swp
3
+ *.gem
4
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-rsync-hg (0.1.0)
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.5)
15
+ i18n (0.7.0)
16
+ net-scp (1.2.1)
17
+ net-ssh (>= 2.6.5)
18
+ net-ssh (2.9.2)
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-hg!
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,69 @@
1
+ # Capistrano 3 deploy with Rsync & Hg
2
+
3
+ Deploy with Rsync to your server from a local Mercurial repository when using Capistrano. Saves
4
+ you from having to install Mercurial on your production machine and allows you to customize which
5
+ files you want to deploy.
6
+
7
+ >> **NOTE**: This library is a derivation of a Git flavored original [moll/capistrano-rsync](https://github.com/moll/capistrano-rsync)
8
+
9
+ ## Using
10
+
11
+ Install with:
12
+
13
+ gem install capistrano-rsync-hg # 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://hg@bitbucket.org/myusername/myrepository"
27
+ set :branch, "default"
28
+ set :rsync_exclude, %w[ .hg* ]
29
+ set :rsync_options, %w[ --archive --recursive --delete --delete-excluded ]
30
+ set :local_cache, ".cache_#{fetch(:stage)}"
31
+ set :remote_cache, "shared/cache"
32
+
33
+ * `:user` - the user used in the rsync connection (optional).
34
+ * `:repo_url` - the repository to clone.
35
+ * `:branch` - the branch to checkout.
36
+ * `:rsync_exclude` - array of files/paths to exclude from rsync (optional).
37
+ * `:rsync_options` - additional rsync options (optional).
38
+ * `:local_cache` - the local cache folder (where the repo will be checked out) - either absolute or relative to the local project root.
39
+ * `:remote_cache` - the remote cache folder (where the files will be rsynced to) - either absolute or relative to capistrano `deploy_to` variable.
40
+
41
+ And after setting regular Capistrano options, deploy as usual:
42
+
43
+ cap production deploy
44
+
45
+ ## Implementation
46
+
47
+ 1. Clones and updates your repository to `local_cache` on your local machine.
48
+ 2. Checks out the branch set in the branch variable.
49
+ 3. Rsyncs to the `remote_cache` directory on the server.
50
+ 4. Copies the content of the `remote_cache` directory to a new release directory.
51
+
52
+ After that, Capistrano takes over and runs its usual tasks and symlinking.
53
+
54
+ ## Exclude files from being deployed
55
+
56
+ If you don't want to deploy everything you've committed to your repository, specify `:rsync_exclude`
57
+
58
+ set :rsync_exclude, %w[
59
+ .hg*
60
+ /config/database.yml
61
+ /test/***
62
+ ]
63
+
64
+ ## Other tasks
65
+
66
+ cap rsync:stage # checkout the repo/branch into the :local_cache
67
+ cap rsync:sync # ... and sync to the server(s)
68
+ cap rsync:release # ... and copy to a release folder (but WITHOUT symlinking the current directory)
69
+
@@ -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,13 @@
1
+ module Capistrano
2
+ module Rsync
3
+ NAME = "capistrano-rsync-hg"
4
+ VERSION = "0.1.0"
5
+ AUTHORS = [ "Jake Gordon" ]
6
+ EMAIL = "jake@codeincomplete.com"
7
+ HOMEPAGE = "http://codeincomplete.com/"
8
+ SUMMARY = "Capistrano v3 deploy with rsync from a local Hg repository"
9
+ DESCRIPTION = "Deploy your application using Capistrano v3 without requiring SCM access on the server - checkout the repository locally (using Hg) and deploy with Rsync"
10
+ LICENSE = "MIT"
11
+ end
12
+ end
13
+
@@ -0,0 +1,80 @@
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[.hg*]
11
+ set :rsync_options, %w[--archive --recursive --delete --delete-excluded]
12
+ set :copy_command, "rsync --archive --acls --xattrs"
13
+ set :local_cache, ".rsync_#{fetch(:stage)}"
14
+ set :remote_cache, "shared/rsync"
15
+ set :repo_url, File.expand_path(".")
16
+ end
17
+ end
18
+
19
+ namespace "rsync" do
20
+
21
+ task :check do
22
+ # nothing to check, but expected by framework
23
+ end
24
+
25
+ task :create_cache do
26
+ next if File.directory?(File.expand_path(fetch(:local_cache))) # TODO: check if it's actually our repo instead of assuming
27
+ run_locally do
28
+ execute :hg, 'clone', fetch(:repo_url), fetch(:local_cache)
29
+ end
30
+ end
31
+
32
+ desc "stage the repository in a local directory"
33
+ task :stage => [ :create_cache ] do
34
+ run_locally do
35
+ within fetch(:local_cache) do
36
+ execute :hg, "pull"
37
+ execute :hg, "checkout #{fetch(:branch)}"
38
+ end
39
+ end
40
+ end
41
+
42
+ desc "stage and rsync to the server"
43
+ task :sync => [ :stage ] do
44
+ release_roles(:all).each do |role|
45
+
46
+ user = role.user || fetch(:user)
47
+ user = user + "@" unless user.nil?
48
+
49
+ rsync_args = []
50
+ rsync_args.concat fetch(:rsync_options)
51
+ rsync_args.concat fetch(:rsync_exclude, []).map{|e| "--exclude #{e}"}
52
+ rsync_args << fetch(:local_cache) + "/"
53
+ rsync_args << "#{user}#{role.hostname}:#{remote_cache.call}"
54
+
55
+ run_locally do
56
+ execute :rsync, *rsync_args
57
+ end
58
+ end
59
+ end
60
+
61
+ desc "stage, rsync to the server, and copy the code to the releases directory"
62
+ task :release => [ :sync ] do
63
+ copy = %(#{fetch(:copy_command)} "#{remote_cache.call}/" "#{release_path}/")
64
+ on release_roles(:all) do
65
+ execute copy
66
+ end
67
+ end
68
+
69
+ task :create_release => [ :release ] do
70
+ # expected by the framework, delegate to better named task
71
+ end
72
+
73
+ task :set_current_revision do
74
+ run_locally do
75
+ set :current_revision, capture(:hg, 'log', "--rev #{fetch(:branch)}", "--template \"{node|short}\"")
76
+ end
77
+ end
78
+
79
+ end
80
+
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-rsync-hg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jake Gordon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-07 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: Deploy your application using Capistrano v3 without requiring SCM access
34
+ on the server - checkout the repository locally (using Hg) and deploy with Rsync
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-hg.gemspec
47
+ - lib/capistrano/rsync.rb
48
+ - lib/capistrano/rsync/version.rb
49
+ homepage: http://codeincomplete.com/
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
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Capistrano v3 deploy with rsync from a local Hg repository
74
+ test_files: []