mina-rsync 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +2 -0
- data/LICENSE +20 -0
- data/Makefile +12 -0
- data/README.md +111 -0
- data/lib/mina/rsync.rb +79 -0
- data/lib/mina/rsync/version.rb +5 -0
- data/mina-rsync.gemspec +30 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDNmYTkyYWQyYzAxMjhjOWNjNTY1YWNiOWExZWEyODBlMGE5MTAxZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzEwNDEyZDZiNTAyYWEzYzY5MGEwMzg2NDY3MDJmZjNjYTc2MjJjMw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWVkNjFjZDAxOWI1ZWI2MjQyOTQ2ZGU2ZTY0MmMyOWNkODZlZDdmN2M2Yzc5
|
10
|
+
NjgxMGM3NDNmMmFlZWVkN2ZjNjA2OWYyZTc4ODYwNzE1OTUwNDM4YzI5MGIy
|
11
|
+
MzE4YjUzNzNhMWNlZjliOTE4OTZjM2EwNmQ3ZWZhMWI3YzdmNzI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mjg4ODcxMjBlNzAyOTFjZTRjY2VjMzUwYzEwOTkzZjg2ODE2ZmI5Zjk1N2Uy
|
14
|
+
NGViMjM4MmU1YTRkZmMzYjk1NjNiYTM4ZTI1YWVjMzQ2Mjc1OGNhNDgwOWE3
|
15
|
+
ZWRmM2E0YmJjMDMxNzAwMWU0NTExMzI5ZGZlMWRmZDE3ZTk0NmQ=
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/*.gem
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Mina::Rsync
|
2
|
+
Copyright (C) 2013 Andri Möll
|
3
|
+
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
5
|
+
the terms of the GNU Affero General Public License as published by the Free
|
6
|
+
Software Foundation, either version 3 of the License, or any later version.
|
7
|
+
|
8
|
+
Additional permission under the GNU Affero GPL version 3 section 7:
|
9
|
+
If you modify this Program, or any covered work, by linking or
|
10
|
+
combining it with other code, such other code is not for that reason
|
11
|
+
alone subject to any of the requirements of the GNU Affero GPL version 3.
|
12
|
+
|
13
|
+
In summary:
|
14
|
+
- You can use this program for no cost.
|
15
|
+
- You can use this program for both personal and commercial reasons.
|
16
|
+
- You do not have to share your own program's code which uses this program.
|
17
|
+
- You have to share modifications (e.g bug-fixes) you've made to this program.
|
18
|
+
|
19
|
+
For the full copy of the GNU Affero General Public License see:
|
20
|
+
http://www.gnu.org/licenses.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
Mina::Rsync for Mina
|
2
|
+
====================
|
3
|
+
[![Gem version](https://badge.fury.io/rb/mina-rsync.png)](http://badge.fury.io/rb/mina-rsync)
|
4
|
+
|
5
|
+
**Deploy with Rsync** to your server from any local (or remote) repository when using [**Mina**](http://nadarei.co/mina).
|
6
|
+
Saves you from having to install Git on your production machine and allows you to customize which files you want to deploy. Also allows you to easily precompile things on your local machine before deploying.
|
7
|
+
|
8
|
+
### Tour
|
9
|
+
- Suitable for deploying any apps, be it Ruby, Rails, Node.js or others.
|
10
|
+
- Exclude files from being deployed with Rsync's `--exclude` options.
|
11
|
+
- Precompile files or assets easily before deploying, like JavaScript or CSS.
|
12
|
+
- Caches your previously deployed code to speed up deployments ~1337%.
|
13
|
+
- Currently works only with Git, so please shout out your interest in other SCMs.
|
14
|
+
|
15
|
+
|
16
|
+
Using
|
17
|
+
-----
|
18
|
+
Install with:
|
19
|
+
```
|
20
|
+
gem install mina-rsync
|
21
|
+
```
|
22
|
+
|
23
|
+
Require it at the top of your `Minafile` (or `config/deploy.rb`):
|
24
|
+
```ruby
|
25
|
+
require "mina/rsync"
|
26
|
+
```
|
27
|
+
|
28
|
+
Set some `rsync_options` to your liking:
|
29
|
+
```ruby
|
30
|
+
set :rsync_options, %w[--recursive --delete --delete-excluded --exclude .git*]
|
31
|
+
```
|
32
|
+
|
33
|
+
Then invoke Mina::Rsync's tasks from your `deploy` task:
|
34
|
+
```ruby
|
35
|
+
task :deploy do
|
36
|
+
deploy do
|
37
|
+
invoke "rsync:deploy"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
And after setting regular Mina options, deploy as usual!
|
43
|
+
```
|
44
|
+
mina deploy
|
45
|
+
```
|
46
|
+
|
47
|
+
### Implementation
|
48
|
+
1. Clones and updates your repository to `rsync_stage` (defaults to `tmp/deploy`) on your local machine.
|
49
|
+
2. Checks out the branch set in the `branch` variable (defaults to `master`).
|
50
|
+
3. Rsyncs to `rsync_cache` (defaults to `shared/deploy`) on the server.
|
51
|
+
4. Copies the content of the cache directory to the build directory.
|
52
|
+
|
53
|
+
After that, Mina takes over and runs its usual tasks and symlinking.
|
54
|
+
|
55
|
+
### Excluding files from being deployed
|
56
|
+
If you don't want to deploy everything you've committed to your repository, pass some `--exclude` options to Rsync:
|
57
|
+
```ruby
|
58
|
+
set :rsync_options, %w[
|
59
|
+
--recursive --delete --delete-excluded
|
60
|
+
--exclude .git*
|
61
|
+
--exclude /config/database.yml
|
62
|
+
--exclude /test/***
|
63
|
+
]
|
64
|
+
```
|
65
|
+
|
66
|
+
### Precompile assets before deploy
|
67
|
+
Mina::Rsync runs `rsync:stage` before rsyncing. Hook to that like this:
|
68
|
+
```ruby
|
69
|
+
task :precompile do
|
70
|
+
Dir.chdir settings.rsync_stage do
|
71
|
+
system "rake", "assets:precompile"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
task "rsync:stage" do
|
76
|
+
invoke "precompile"
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
|
81
|
+
Configuration
|
82
|
+
-------------
|
83
|
+
Set Mina variables with `set name, value`.
|
84
|
+
|
85
|
+
Name | Default | Description
|
86
|
+
--------------|---------|------------
|
87
|
+
repository | `.` | The path or URL to a Git repository to clone from.
|
88
|
+
branch | `master` | The Git branch to checkout.
|
89
|
+
rsync_stage | `tmp/deploy` | Path where to clone your repository for staging, checkouting and rsyncing. Can be both relative or absolute.
|
90
|
+
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.
|
91
|
+
rsync_options | `[]` | Array of options to pass to `rsync`.
|
92
|
+
|
93
|
+
|
94
|
+
License
|
95
|
+
-------
|
96
|
+
Mina::Rsync is released under a *Lesser GNU Affero General Public License*, which in summary means:
|
97
|
+
|
98
|
+
- You **can** use this program for **no cost**.
|
99
|
+
- You **can** use this program for **both personal and commercial reasons**.
|
100
|
+
- You **do not have to share your own program's code** which uses this program.
|
101
|
+
- You **have to share modifications** (e.g bug-fixes) you've made to this program.
|
102
|
+
|
103
|
+
For more convoluted language, see the `LICENSE` file.
|
104
|
+
|
105
|
+
|
106
|
+
About
|
107
|
+
-----
|
108
|
+
**[Andri Möll](http://themoll.com)** made this happen.
|
109
|
+
[Monday Calendar](https://mondayapp.com) was the reason I needed this.
|
110
|
+
|
111
|
+
If you find Mina::Rsync needs improving, please don't hesitate to type to me now at [andri@dot.ee](mailto:andri@dot.ee) or [create an issue online](https://github.com/moll/mina-rsync/issues).
|
data/lib/mina/rsync.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path("../rsync/version", __FILE__)
|
2
|
+
|
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 Mina::Rsync. If you think something should be public
|
6
|
+
# for extending, please let me know!
|
7
|
+
|
8
|
+
set_default :repository, "."
|
9
|
+
set_default :branch, "master"
|
10
|
+
set_default :rsync_options, []
|
11
|
+
set_default :rsync_copy, "rsync --archive --acls --xattrs"
|
12
|
+
|
13
|
+
# Stage is used on your local machine for rsyncing from.
|
14
|
+
set_default :rsync_stage, "tmp/deploy"
|
15
|
+
|
16
|
+
# Cache is used on the server to copy files to from to the release directory.
|
17
|
+
# Saves you rsyncing your whole app folder each time.
|
18
|
+
set_default :rsync_cache, "shared/deploy"
|
19
|
+
|
20
|
+
run = lambda do |*cmd|
|
21
|
+
if simulate_mode?
|
22
|
+
puts "$ #{cmd.join(" ")}"
|
23
|
+
else
|
24
|
+
Kernel.system *cmd
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
rsync_cache = lambda do
|
29
|
+
cache = settings.rsync_cache
|
30
|
+
raise TypeError, "Please set rsync_cache." unless cache
|
31
|
+
cache = settings.deploy_to + "/" + cache if cache && cache !~ /^\//
|
32
|
+
cache
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Stage and rsync to the server (or its cache)."
|
36
|
+
task :rsync => %w[rsync:stage] do
|
37
|
+
puts "Rsyncing to #{rsync_cache.call}..."
|
38
|
+
|
39
|
+
rsync = %w[rsync]
|
40
|
+
rsync.concat settings.rsync_options
|
41
|
+
rsync << settings.rsync_stage + "/"
|
42
|
+
|
43
|
+
user = settings.user + "@" if settings.user
|
44
|
+
host = settings.domain
|
45
|
+
rsync << "#{user}#{host}:#{rsync_cache.call}"
|
46
|
+
|
47
|
+
run.call *rsync
|
48
|
+
end
|
49
|
+
|
50
|
+
namespace :rsync do
|
51
|
+
task :create_stage do
|
52
|
+
next if File.directory?(settings.rsync_stage)
|
53
|
+
puts "Cloning repository for the first time..."
|
54
|
+
|
55
|
+
clone = %W[git clone]
|
56
|
+
clone << settings.repository
|
57
|
+
clone << settings.rsync_stage
|
58
|
+
run.call *clone
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Stage the repository in a local directory."
|
62
|
+
task :stage => %w[create_stage] do
|
63
|
+
puts "Staging..."
|
64
|
+
|
65
|
+
puts "$ cd #{settings.rsync_stage}" if simulate_mode?
|
66
|
+
Dir.chdir settings.rsync_stage do
|
67
|
+
run.call *%W[git fetch --quiet --all --prune]
|
68
|
+
print "Git checkout: "
|
69
|
+
run.call *%W[git reset --hard origin/#{settings.branch}]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
task :build do
|
74
|
+
queue %(#{settings.rsync_copy} "#{rsync_cache.call}/" ".")
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Stage, rsync and copy to the build path."
|
78
|
+
task :deploy => %w[rsync build]
|
79
|
+
end
|
data/mina-rsync.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path("../lib/mina/rsync/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "mina-rsync"
|
5
|
+
gem.version = Mina::Rsync::VERSION
|
6
|
+
gem.homepage = "https://github.com/moll/mina-rsync"
|
7
|
+
gem.summary = <<-end.strip.gsub(/\s*\n\s*/, " ")
|
8
|
+
Deploy with Rsync from any local (or remote) repository.
|
9
|
+
end
|
10
|
+
|
11
|
+
gem.description = <<-end.strip.gsub(/\s*?\n(\n?)\s*/, " \\1\\1")
|
12
|
+
Deploy with Rsync to your server from any local (or remote) repository.
|
13
|
+
|
14
|
+
Saves you the need to install Git on your production machine and deploy all
|
15
|
+
of your development files each time!
|
16
|
+
|
17
|
+
Suitable for deploying any apps, be it Ruby or Node.js.
|
18
|
+
end
|
19
|
+
|
20
|
+
gem.author = "Andri Möll"
|
21
|
+
gem.email = "andri@dot.ee"
|
22
|
+
gem.license = "LAGPL"
|
23
|
+
|
24
|
+
gem.files = `git ls-files`.split($/)
|
25
|
+
gem.executables = gem.files.grep(/^bin\//).map(&File.method(:basename))
|
26
|
+
gem.test_files = gem.files.grep(/^spec\//)
|
27
|
+
gem.require_paths = ["lib"]
|
28
|
+
|
29
|
+
gem.add_dependency "mina", ">= 0.3.0", "< 2"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mina-rsync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andri Möll
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mina
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
description: ! "Deploy with Rsync to your server from any local (or remote) repository.
|
34
|
+
\n\nSaves you the need to install Git on your production machine and deploy all
|
35
|
+
of your development files each time! \n\nSuitable for deploying any apps, be it
|
36
|
+
Ruby or Node.js."
|
37
|
+
email: andri@dot.ee
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- .gitignore
|
43
|
+
- CHANGELOG.md
|
44
|
+
- LICENSE
|
45
|
+
- Makefile
|
46
|
+
- README.md
|
47
|
+
- lib/mina/rsync.rb
|
48
|
+
- lib/mina/rsync/version.rb
|
49
|
+
- mina-rsync.gemspec
|
50
|
+
homepage: https://github.com/moll/mina-rsync
|
51
|
+
licenses:
|
52
|
+
- LAGPL
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
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.0.6
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Deploy with Rsync from any local (or remote) repository.
|
74
|
+
test_files: []
|
75
|
+
has_rdoc:
|