rake-deploy 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/lib/rake/deploy/deploy.rb +19 -0
- data/lib/rake/deploy/object.rb +5 -0
- data/lib/rake/deploy.rb +61 -0
- data/rake-deploy.gemspec +14 -0
- metadata +115 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) <2010> <Guillermo Álvarez Fernández>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Rake-deploy
|
2
|
+
|
3
|
+
A deploy system using rake. Maybe a light version of capistrano
|
4
|
+
|
5
|
+
## Motivation
|
6
|
+
|
7
|
+
Capistrano is a great project, maybe a little big in some cases, but with one big problem: it aims to cover all possible use cases.
|
8
|
+
|
9
|
+
rake-deploy is like a simple version of capistrano, and only intended to be the clumping of the most common to all projects: The management of versions of code.
|
10
|
+
|
11
|
+
The basic operation of rake-deploy is based on three principles:
|
12
|
+
|
13
|
+
* Add a configuration task environment.
|
14
|
+
* A set of tasks provided by rake-deploy.
|
15
|
+
* Hooks for each of the tasks with rake-hooks
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
In your Rakefile add:
|
20
|
+
|
21
|
+
require 'rake/deploy'
|
22
|
+
|
23
|
+
In any of your task files (for example, for rails: lib/tasks/deploy.rake)
|
24
|
+
|
25
|
+
deploy.application = "app_name"
|
26
|
+
deploy.deploy_to = "/apps/app_name"
|
27
|
+
deploy.repository = "ssh://user@github.com/myrepo.git"
|
28
|
+
deploy.host = "esther.cientifico.net"
|
29
|
+
|
30
|
+
Now you can do:
|
31
|
+
rake deploy:setup # To create app skeleton
|
32
|
+
rake deploy # To deploy
|
33
|
+
|
34
|
+
## Recipes
|
35
|
+
|
36
|
+
For example, imagine you wan't to restart passanger, rake-deploy will not do it for you so just write:
|
37
|
+
|
38
|
+
after :deploy do
|
39
|
+
deploy.run(deploy.host, "touch #{deploy.deploy_to}/current/tmp/restart.txt")
|
40
|
+
end
|
41
|
+
|
42
|
+
Or you want to make a backup of your database in each deploy
|
43
|
+
|
44
|
+
before :deploy do
|
45
|
+
deploy.run("db.my_company.com", "mysqldump -u root my_app_db_production | gzip > /var/backups/#{deploy.release_name}.db.sql.bz2")
|
46
|
+
end
|
47
|
+
|
48
|
+
You can see more recipes, that you most copy and paste and edit in your files in the wiki:
|
49
|
+
|
50
|
+
http://wiki.github.com/guillermo/rake-deploy/recipes
|
51
|
+
|
52
|
+
## Conventions
|
53
|
+
|
54
|
+
* Use git.
|
55
|
+
* Don't use sudo (really need super user to deploy?)
|
56
|
+
* Use ssh keys from you to the server and from the server to the repo
|
57
|
+
* Use /current /releases/#{date} /shared schema in server (deploy:setup makes it for you)
|
58
|
+
* Use /shared/scaffold as a scaffold of your app. There will be the data shared between releases like database.yml, /tmp, /log or /public/shared
|
59
|
+
* User /shared/repo as a bare clone of your remote remote
|
60
|
+
|
61
|
+
## Author
|
62
|
+
|
63
|
+
Guillermo Álvarez <guillermo@cientifico.net>
|
64
|
+
|
65
|
+
## Web
|
66
|
+
|
67
|
+
http://github.com/guillermo/rake-deploy
|
68
|
+
|
69
|
+
## Date of writing
|
70
|
+
|
71
|
+
22 Jul 2010
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Deploy < OpenStruct
|
2
|
+
def initialize
|
3
|
+
super
|
4
|
+
@ssh_sessions = {}
|
5
|
+
self.branch = "master"
|
6
|
+
self.rails_env = "production"
|
7
|
+
self.shared = %w(/tmp /log /public/system)
|
8
|
+
self.user = `who am i`.split(" ").first
|
9
|
+
end
|
10
|
+
|
11
|
+
def run(host,command)
|
12
|
+
puts " #{host}$ #{command}"
|
13
|
+
@ssh_sessions["#{host}#{user}"] ||= Net::SSH.start(host, user)
|
14
|
+
output = @ssh_sessions["#{host}#{user}"].exec!(command)
|
15
|
+
puts output.split("\n").map{|l| " #{host}> #{l}"}.join("\n") if output
|
16
|
+
output
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/rake/deploy.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'rake/hooks'
|
4
|
+
require 'rake/deploy/deploy'
|
5
|
+
require 'rake/deploy/object'
|
6
|
+
|
7
|
+
desc 'Deploy the application'
|
8
|
+
task :deploy => ["deploy:symlink"]
|
9
|
+
|
10
|
+
|
11
|
+
namespace :deploy do
|
12
|
+
|
13
|
+
desc 'Generate timestamp for revision name'
|
14
|
+
task :generate_timestamp do
|
15
|
+
deploy.release_name ||= Time.now.utc.strftime("%Y%m%d%H%M.%S")
|
16
|
+
deploy.release_path ||= "#{deploy.deploy_to}/releases/#{deploy.release_name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Update remote repo'
|
20
|
+
task :update_repo do
|
21
|
+
puts "=> update_repo"
|
22
|
+
deploy.run(deploy.host, "cd #{deploy.deploy_to}/shared/repo && git fetch")
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Checkout newer version'
|
26
|
+
task :checkout => [:generate_timestamp,:update_repo] do
|
27
|
+
puts "=> checkout"
|
28
|
+
deploy.run(deploy.host, "mkdir -p #{deploy.deploy_to}/releases/")
|
29
|
+
deploy.run(deploy.host, "git clone -s #{deploy.deploy_to}/shared/repo #{deploy.release_path} && cd #{deploy.release_path} && git checkout #{deploy.branch}")
|
30
|
+
deploy.shared.each do |shared_path|
|
31
|
+
deploy.run(deploy.host, "rm -rf #{deploy.release_path}#{shared_path}")
|
32
|
+
deploy.run(deploy.host, "ln -s #{deploy.deploy_to}/shared/scaffold#{shared_path} #{deploy.release_path}#{shared_path}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Symlink to new version'
|
37
|
+
task :symlink => [:checkout] do
|
38
|
+
puts "=> symlink"
|
39
|
+
deploy.run(deploy.host, "unlink #{deploy.deploy_to}/current")
|
40
|
+
deploy.run(deploy.host, "ln -s #{deploy.release_path} #{deploy.deploy_to}/current")
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Setup'
|
44
|
+
task :setup do
|
45
|
+
puts "=> setup"
|
46
|
+
%w(/releases /shared/scaffold/tmp /shared/scaffold/log).each do |path|
|
47
|
+
deploy.run(deploy.host, "mkdir -p #{deploy.deploy_to}#{path}")
|
48
|
+
end
|
49
|
+
|
50
|
+
deploy.run(deploy.host, "ln -s #{deploy.deploy_to}/shared/scaffold/tmp #{deploy.deploy_to}/shared/tmp ")
|
51
|
+
deploy.run(deploy.host, "ln -s #{deploy.deploy_to}/shared/scaffold/log #{deploy.deploy_to}/shared/log ")
|
52
|
+
|
53
|
+
deploy.run(deploy.host, "git clone --bare #{deploy.repository} #{deploy.deploy_to}/shared/repo")
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
after :deploy do
|
59
|
+
puts "=> restart"
|
60
|
+
deploy.run(deploy.host, "touch #{deploy.deploy_to}/current/tmp/restart.txt")
|
61
|
+
end
|
data/rake-deploy.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "rake-deploy"
|
3
|
+
s.version = "0.1"
|
4
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
5
|
+
s.authors = ["Guillermo Álvarez"]
|
6
|
+
s.email = "guillermo@cientifico.net"
|
7
|
+
s.summary = "A capistrano without magic that use simple rake tasks"
|
8
|
+
s.homepage = "http://github.com/guillermo/rake-deploy"
|
9
|
+
s.description = "Create some conventions and a deploy system using just rake"
|
10
|
+
s.files = `find *`.split("\n")
|
11
|
+
s.add_dependency("rake", "> 0.8.0")
|
12
|
+
s.add_dependency("rake-hooks")
|
13
|
+
s.add_dependency("net-ssh")
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "Guillermo \xC3\x81lvarez"
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-22 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 63
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 8
|
32
|
+
- 0
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake-hooks
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: net-ssh
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
description: Create some conventions and a deploy system using just rake
|
65
|
+
email: guillermo@cientifico.net
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
files:
|
73
|
+
- LICENSE
|
74
|
+
- README.md
|
75
|
+
- lib/rake/deploy/deploy.rb
|
76
|
+
- lib/rake/deploy/object.rb
|
77
|
+
- lib/rake/deploy.rb
|
78
|
+
- rake-deploy-0.1.gem
|
79
|
+
- rake-deploy.gemspec
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/guillermo/rake-deploy
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.3.7
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: A capistrano without magic that use simple rake tasks
|
114
|
+
test_files: []
|
115
|
+
|