capistrano-rsync 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTBjYTRmOWQ1NGZhMTAyYTFiMmMwYjcwNTVmNTI2Zjg4NTI2MDU2Nw==
4
+ OGIzNmE1Njc0MzhkZmI5MTAzMTMyMDZkNTczMWQ0NzNiMTczMzkyZA==
5
5
  data.tar.gz: !binary |-
6
- YzcxZWE4YTIxNWVkY2Y1ZDY3YzhiZGFkNmMwNzFlNzVkNmU0MTEyOA==
6
+ Y2FmMDdmZGMyZDkyNmM5YTcwOGQxOTliNGJkYzVmMTUwOGU3YzkyNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NmE5YzQwZjE0NTE5ODcyNjI4YjE1ZGQ1NDQ4ZDY4MGE1NTM4YjJjM2FlMWYz
10
- ZGY5MzQ5NGMxOTQxZTRhNGNlZjY5NWZkMjQ1NDY2ZjQzZGRjOTdlODI4Nzcz
11
- MTFkNjA4OGQwZTAwYjQ5Y2Y2YjEwMDkxOWRkMDdhZTVjNzc2Mzk=
9
+ ZjFhNmQxMjJmYjFmNDE2OWIzMDZlYTkxZTI1NzIxZjEzNDdmOGNlMjNkMDZk
10
+ OTg1ZGE2Y2U0NWUwZTQ4ZWNiYzBjYzdhMDRjNGRlNWU5ZjAyOWE2YzI0ZmFl
11
+ YWQxNDVjZmRjZWFjOGYwZTY5MTk1ZDNkOWFhOTg1MDJjNmFmY2E=
12
12
  data.tar.gz: !binary |-
13
- NGVmZTJmZTUwNWNmZWRhNjk5Njc3ZWUzODk4ZGU3NWI1MmRjYTAxZTBmZDBj
14
- OTlkMmI5MzI0ZDVkZTlhNjMyMGY0ODc5YzIyOWRjMDAxY2UzM2ZkYWQ5MjM3
15
- OTZlNTQ1ZGMwM2Q3ZjAzZjUxNjZiZmY1MmMwMmVkMDEzZGU0Mzc=
13
+ ZjRhMzVjZjg3NWRhOTY2MDZmYjUwMjg5YmU1MjMyMjZkNTE0YjY1MmViODll
14
+ OGJiNzExMGM2OWVjOTI1ODA3NDVjM2FhMDRiY2EwNjk0MThhNTZlNzk0MWFl
15
+ OTkzMDQ4Yjc3YTUwNDQwYWIxMDc3MDFhNjRjZjA2MDljNjA2OWQ=
data/CHANGELOG.md CHANGED
@@ -1,12 +1,17 @@
1
- # 0.2.1 (Sep 1, 2013)
1
+ ## 1.0.0 (Sep 2, 2013)
2
+ - Makes the `rsync:stage` task public for extending and hooking.
3
+ - Rename `rsync:create_release` to `rsync:release`. Old name still works.
4
+ - Adds optional caching to `rsync_cache` directory on the server.
5
+
6
+ ## 0.2.1 (Sep 1, 2013)
2
7
  - Fixes starting with no previous local repository cache.
3
8
  Note to self: Avoid writing code without integration tests.
4
9
 
5
- # 0.2.0 (Sep 1, 2013)
10
+ ## 0.2.0 (Sep 1, 2013)
6
11
  - Passes user given in `role :app, "user@host"` to `rsync` if set.
7
12
 
8
- # 0.1.338 (Sep 1, 2013)
13
+ ## 0.1.338 (Sep 1, 2013)
9
14
  - Adds gem dependency on Capistrano v3.
10
15
 
11
- # 0.1.337 (Sep 1, 2013)
16
+ ## 0.1.337 (Sep 1, 2013)
12
17
  - First release. Let's get syncing!
data/README.md CHANGED
@@ -2,11 +2,16 @@ Capistrano::Rsync for Capistrano v3
2
2
  ===================================
3
3
  [![Gem version](https://badge.fury.io/rb/capistrano-rsync.png)](http://badge.fury.io/rb/capistrano-rsync)
4
4
 
5
- Deploy with Rsync to your server from any local (or remote) repository.
6
- Saves you from having to install Git on your production machine and allows you to customize which files you want to deploy.
5
+ **Deploy with Rsync** to your server from any local (or remote) repository when using [**Capistrano**](http://www.capistranorb.com/).
6
+ Saves you from having to install Git on your production machine and allows you to customize which files you want to deploy. Allows also you to easily precompile things on your local machine before deploying.
7
7
 
8
- Works with the new [**Capistrano v3**](http://www.capistranorb.com/) and is suitable for deploying any apps, be it Ruby or Node.js.
9
- Currently works **only with Git** (as does Capistrano v3), so please shout out your interest in other SCMs.
8
+ ### Tour
9
+ - Works with the new [**Capistrano v3**](http://www.capistranorb.com/) ([source code](https://github.com/capistrano/capistrano)) versions `>= 3.0.0pre14` and `< 4`.
10
+ - Suitable for deploying any apps, be it Ruby, Rails, Node.js or others.
11
+ - Exclude files from being deployed with Rsync's `--exclude` options.
12
+ - Precompile files or assets easily before deploying, like JavaScript or CSS.
13
+ - Caches your previously deployed code to speed up deployments ~1337%.
14
+ - Currently works only with Git (as does Capistrano v3), so please shout out your interest in other SCMs.
10
15
 
11
16
 
12
17
  Using
@@ -16,10 +21,8 @@ Install with:
16
21
  gem install capistrano-rsync
17
22
  ```
18
23
 
19
- Require it at the top of your `Capfile`:
24
+ Require it at the top of your `Capfile` or `config/deploy.rb`:
20
25
  ```ruby
21
- require "capistrano/setup"
22
- require "capistrano/deploy"
23
26
  require "capistrano/rsync"
24
27
  ```
25
28
 
@@ -33,10 +36,10 @@ And after setting regular Capistrano options, deploy as usual!
33
36
  cap deploy
34
37
  ```
35
38
 
36
- ### How does it work?
39
+ ### Implementation
37
40
  Capistrano::Rsync clones your repository to `tmp/cache` on your local machine, checks out the branch set in the `branch` variable (`master` by default) and then Rsyncs that directory to your servers.
38
41
 
39
- ### Excluding files from being deployed
42
+ ### Exclude files from being deployed
40
43
  If you don't want to deploy everything you've committed to your repository, pass some `--exclude` options to Rsync:
41
44
  ```ruby
42
45
  set :rsync_options, %w[
@@ -47,26 +50,35 @@ set :rsync_options, %w[
47
50
  ]
48
51
  ```
49
52
 
53
+ ### Precompile assets before deploy
54
+ Capistrano::Rsync runs `rsync:stage` before rsyncing. Hook to that like this:
55
+ ```ruby
56
+ task :precompile do
57
+ Dir.chdir fetch(:rsync_stage) do
58
+ system "rake", "assets:precompile"
59
+ end
60
+ end
50
61
 
51
- Configuration
52
- -------------
53
- Set Capistrano variables with `set name, value`.
62
+ after "rsync:stage", "precompile"
63
+ ```
54
64
 
55
- #### branch
56
- The Git branch to checkout.
57
- Defaults to `master`.
65
+ ### Deploy release without symlinking the current directory
66
+ ```
67
+ cap rsync:release
68
+ ```
58
69
 
59
- #### repo_url
60
- The path or URL to a Git repository to clone from.
61
- Defaults to `.`.
62
70
 
63
- #### rsync_stage
64
- Location where to clone your repository for staging, checkouting and rsyncing.
65
- Defaults to `tmp/cache`.
71
+ Configuration
72
+ -------------
73
+ Set Capistrano variables with `set name, value`.
66
74
 
67
- #### rsync_options
68
- Array of options to pass to `rsync`.
69
- Defaults to `[]`.
75
+ Name | Default | Description
76
+ --------------|---------|------------
77
+ branch | `master` | The Git branch to checkout.
78
+ repo_url | `.` | The path or URL to a Git repository to clone from.
79
+ rsync_stage | `tmp/deploy` | Path where to clone your repository for staging, checkouting and rsyncing. Can be both relative or absolute.
80
+ rsync_cache | `shared/deploy` | Path where to cache your repository on the server to avoid rsyncing from scratch each time. Can be both relative or absolute.<br> Set to `nil` if you want to disable the cache.
81
+ rsync_options | `[]` | Array of options to pass to `rsync`.
70
82
 
71
83
 
72
84
  License
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Rsync
3
- VERSION = "0.2.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -1,5 +1,89 @@
1
1
  require File.expand_path("../rsync/version", __FILE__)
2
- load File.expand_path("../tasks/rsync.rake", __FILE__)
3
2
 
4
- set :rsync_stage, "tmp/deploy"
3
+ # NOTE: Please don't depend on tasks without a description (`desc`) remaining
4
+ # as they are between minor or patch version releases. They make up the private
5
+ # API and internalas of Capistrano::Rsync. If you think something should be
6
+ # public for extending, please let me know!
7
+
5
8
  set :rsync_options, []
9
+ set :rsync_copy, "rsync --archive --acls --xattrs"
10
+
11
+ # Stage is used on your local machine for rsyncing from.
12
+ set :rsync_stage, "tmp/deploy"
13
+
14
+ # Cache is used on the server to copy files to from to the release directory.
15
+ # Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
16
+ # Capistrano::Rsync will sync straight to the release path.
17
+ set :rsync_cache, "shared/deploy"
18
+
19
+ rsync_cache = lambda do
20
+ cache = fetch(:rsync_cache)
21
+ cache = deploy_to + "/" + cache if cache && cache !~ /^\//
22
+ cache
23
+ end
24
+
25
+ Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
26
+ Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
27
+
28
+ desc "Stage and rsync to the server (or its cache)."
29
+ task :rsync => %w[rsync:stage] do
30
+ roles(:all).each do |role|
31
+ user = role.user + "@" if !role.user.nil?
32
+
33
+ rsync = %w[rsync]
34
+ rsync.concat fetch(:rsync_options)
35
+ rsync << fetch(:rsync_stage) + "/"
36
+ rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
37
+
38
+ Kernel.system *rsync
39
+ end
40
+ end
41
+
42
+ namespace :rsync do
43
+ task :hook_scm do
44
+ Rake::Task.define_task("#{scm}:check") do
45
+ invoke "rsync:check"
46
+ end
47
+
48
+ Rake::Task.define_task("#{scm}:create_release") do
49
+ invoke "rsync:release"
50
+ end
51
+ end
52
+
53
+ task :check do
54
+ # Everything's a-okay inherently!
55
+ end
56
+
57
+ task :create_stage do
58
+ next if File.directory?(fetch(:rsync_stage))
59
+
60
+ clone = %W[git clone]
61
+ clone << fetch(:repo_url, ".")
62
+ clone << fetch(:rsync_stage)
63
+ Kernel.system *clone
64
+ end
65
+
66
+ desc "Stage the repository in a local directory."
67
+ task :stage => %w[create_stage] do
68
+ Dir.chdir fetch(:rsync_stage) do
69
+ update = %W[git fetch --quiet --all --prune]
70
+ Kernel.system *update
71
+
72
+ checkout = %W[git reset --hard origin/#{fetch(:branch)}]
73
+ Kernel.system *checkout
74
+ end
75
+ end
76
+
77
+ desc "Copy the code to the releases directory."
78
+ task :release => %w[rsync] do
79
+ # Skip copying if we've already synced straight to the release directory.
80
+ next if !fetch(:rsync_cache)
81
+
82
+ copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
83
+ on roles(:all).each do execute copy end
84
+ end
85
+
86
+ # Matches the naming scheme of git tasks.
87
+ # Plus was part of the public API in Capistrano::Rsync <= v0.2.1.
88
+ task :create_release => %w[release]
89
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-rsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andri Möll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-01 00:00:00.000000000 Z
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -47,7 +47,6 @@ files:
47
47
  - capistrano-rsync.gemspec
48
48
  - lib/capistrano/rsync.rb
49
49
  - lib/capistrano/rsync/version.rb
50
- - lib/capistrano/tasks/rsync.rake
51
50
  homepage: https://github.com/moll/capistrano-rsync
52
51
  licenses:
53
52
  - LAGPL
@@ -1,51 +0,0 @@
1
- Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
2
- Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
3
-
4
- namespace :rsync do
5
- task :hook_scm do
6
- Rake::Task.define_task("#{scm}:check") do
7
- invoke "rsync:check"
8
- end
9
-
10
- Rake::Task.define_task("#{scm}:create_release") do
11
- invoke "rsync:create_release"
12
- end
13
- end
14
-
15
- task :check do
16
- # Everything's a-okay inherently!
17
- end
18
-
19
- task :create_stage do
20
- next if File.directory?(fetch(:rsync_stage))
21
-
22
- clone = %W[git clone]
23
- clone << fetch(:repo_url, ".")
24
- clone << fetch(:rsync_stage)
25
- Kernel.system *clone
26
- end
27
-
28
- task :update_stage => %w[create_stage] do
29
- Dir.chdir fetch(:rsync_stage) do
30
- update = %W[git fetch --quiet --all --prune]
31
- Kernel.system *update
32
-
33
- checkout = %W[git reset --hard origin/#{fetch(:branch)}]
34
- Kernel.system *checkout
35
- end
36
- end
37
-
38
- desc "Copy the repository to the releases directory."
39
- task :create_release => %w[update_stage] do
40
- roles(:all).each do |role|
41
- user = role.user + "@" if !role.user.nil?
42
-
43
- rsync = %w[rsync]
44
- rsync.concat fetch(:rsync_options)
45
- rsync << fetch(:rsync_stage) + "/"
46
- rsync << "#{user}#{role.hostname}:#{release_path}"
47
-
48
- Kernel.system *rsync
49
- end
50
- end
51
- end