gitploy 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.markdown +68 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/bin/gitploy +2 -0
- data/gitploy.gemspec +46 -0
- data/lib/gitploy.rb +103 -0
- data/lib/gitploy/script.rb +2 -0
- metadata +74 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/README.markdown
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
## Gitploy: dead-simple deployment DSL created with git in mind
|
2
|
+
|
3
|
+
### Why yet another deployment solution?
|
4
|
+
|
5
|
+
* Because Capistrano is bloated
|
6
|
+
* Because, no, I don't want to use rake for deployment, thank you
|
7
|
+
* Because I'm sick of having to jump through flaming hoops just to tweak the arguments of some stupid command
|
8
|
+
* Because I want something bare minimum, git-based, and dead-simple
|
9
|
+
* Because I felt like it
|
10
|
+
|
11
|
+
Gitploy was created to do dead-simple git-push based deployments. It doesn't use rake, it doesn't
|
12
|
+
require git hooks, it just does the bare minimum. It's so minimal, in fact, that it doesn't even
|
13
|
+
come with its own "recipe" - Gitploy is actually just a DSL to quickly define your own deployment
|
14
|
+
strategy. No hooks, very little behind-the-scenes magic - it just does what you tell it to.
|
15
|
+
|
16
|
+
### Example config/deploy.rb
|
17
|
+
|
18
|
+
|
19
|
+
require 'gitploy/script'
|
20
|
+
|
21
|
+
configure do |c|
|
22
|
+
c.repo = 'git@github.com:myuser/fooapp.git'
|
23
|
+
c.path = '/var/www/fooapp'
|
24
|
+
|
25
|
+
stage :staging do
|
26
|
+
c.host = 'staging.fooapp.com'
|
27
|
+
c.user = 'ninja'
|
28
|
+
end
|
29
|
+
|
30
|
+
stage :production do
|
31
|
+
c.host = 'fooapp.com'
|
32
|
+
c.user = 'deployer'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
setup do
|
37
|
+
remote do
|
38
|
+
run "mkdir -p #{config.path}"
|
39
|
+
run "cd #{config.path} && git init"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
deploy do
|
44
|
+
push!
|
45
|
+
remote do
|
46
|
+
run "cd #{config.path}"
|
47
|
+
run "git reset --hard"
|
48
|
+
run "bundle install --deployment"
|
49
|
+
run "touch tmp/restart.txt"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
### Usage
|
54
|
+
|
55
|
+
$ gem install gitploy
|
56
|
+
# create config/deploy.rb
|
57
|
+
$ gitploy production setup
|
58
|
+
$ gitploy production
|
59
|
+
|
60
|
+
### Disclaimer
|
61
|
+
|
62
|
+
Gitploy is super alpha - don't use it yet, unless you're just that baller. Are you?
|
63
|
+
|
64
|
+
### Known issues
|
65
|
+
|
66
|
+
* No tests :(
|
67
|
+
* Not enough documentation
|
68
|
+
* DSL implementation is pretty dumb and needs refactoring
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "gitploy"
|
5
|
+
gemspec.summary = "Deployment DSL created with git in mind"
|
6
|
+
gemspec.description = "Dead-simple deployments. No, for real this time."
|
7
|
+
gemspec.email = "brentdillingham@gmail.com"
|
8
|
+
gemspec.homepage = "http://github.com/brentd/gitploy"
|
9
|
+
gemspec.authors = ["Brent Dillingham"]
|
10
|
+
end
|
11
|
+
Jeweler::GemcutterTasks.new
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
14
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/bin/gitploy
ADDED
data/gitploy.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gitploy}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brent Dillingham"]
|
12
|
+
s.date = %q{2010-09-14}
|
13
|
+
s.default_executable = %q{gitploy}
|
14
|
+
s.description = %q{Dead-simple deployments. No, for real this time.}
|
15
|
+
s.email = %q{brentdillingham@gmail.com}
|
16
|
+
s.executables = ["gitploy"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.markdown"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gitignore",
|
22
|
+
"README.markdown",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/gitploy",
|
26
|
+
"gitploy.gemspec",
|
27
|
+
"lib/gitploy.rb",
|
28
|
+
"lib/gitploy/script.rb"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/brentd/gitploy}
|
31
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.7}
|
34
|
+
s.summary = %q{Deployment DSL created with git in mind}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
else
|
42
|
+
end
|
43
|
+
else
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/gitploy.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
module Gitploy
|
2
|
+
extend self
|
3
|
+
attr_accessor :config
|
4
|
+
|
5
|
+
class Config
|
6
|
+
REQUIRED_OPTIONS = [:repo, :path, :user, :host]
|
7
|
+
attr_accessor *REQUIRED_OPTIONS
|
8
|
+
|
9
|
+
def check!
|
10
|
+
unless missing_options.empty?
|
11
|
+
raise "The following configuration options are missing for the '#{Gitploy.current_stage}' stage: #{missing_options.join(', ')}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def missing_options
|
16
|
+
REQUIRED_OPTIONS.select {|m| send(m).nil? }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
config = Config.new
|
22
|
+
yield config; config.check!
|
23
|
+
self.config = config
|
24
|
+
end
|
25
|
+
|
26
|
+
def current_stage
|
27
|
+
ARGV[0]
|
28
|
+
end
|
29
|
+
|
30
|
+
def action
|
31
|
+
ARGV[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
def stage(name)
|
35
|
+
yield if name.to_s == current_stage
|
36
|
+
end
|
37
|
+
|
38
|
+
def deploy
|
39
|
+
yield if action.nil? || action == 'deploy'
|
40
|
+
end
|
41
|
+
|
42
|
+
def setup
|
43
|
+
yield if action == 'setup'
|
44
|
+
end
|
45
|
+
|
46
|
+
def remote
|
47
|
+
yield
|
48
|
+
pretty_run(config.host, "ssh #{config.user}@#{config.host} '#{flush_run_queue}'")
|
49
|
+
end
|
50
|
+
|
51
|
+
def local
|
52
|
+
yield
|
53
|
+
pretty_run("LOCAL", flush_run_queue)
|
54
|
+
end
|
55
|
+
|
56
|
+
def run(cmd)
|
57
|
+
run_queue << cmd
|
58
|
+
end
|
59
|
+
|
60
|
+
def sudo(cmd)
|
61
|
+
run("sudo #{cmd}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def rake(task)
|
65
|
+
run("rake #{task}")
|
66
|
+
end
|
67
|
+
|
68
|
+
def push!
|
69
|
+
local { run "git push #{config.user}@#{config.host}:#{config.path}/.git master" }
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def pretty_run(title, cmd)
|
75
|
+
puts
|
76
|
+
print_bar(100, title)
|
77
|
+
puts "> #{cmd}"
|
78
|
+
puts
|
79
|
+
Kernel.system(cmd)
|
80
|
+
print_bar(100)
|
81
|
+
end
|
82
|
+
|
83
|
+
def print_bar(width, title=nil)
|
84
|
+
if title
|
85
|
+
half_width = (width / 2) - (title.length / 2) - 2
|
86
|
+
left_bar = '=' * half_width
|
87
|
+
right_bar = '=' * (title.length % 2 == 0 ? half_width : half_width - 1) # TODO: lame.
|
88
|
+
puts "#{left_bar}( #{title} )#{right_bar}"
|
89
|
+
else
|
90
|
+
puts "=" * width
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def run_queue
|
95
|
+
@run_queue ||= []
|
96
|
+
end
|
97
|
+
|
98
|
+
def flush_run_queue
|
99
|
+
cmd = run_queue.join(' && ')
|
100
|
+
@run_queue = []
|
101
|
+
cmd
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Brent Dillingham
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-14 00:00:00 -04:00
|
19
|
+
default_executable: gitploy
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Dead-simple deployments. No, for real this time.
|
23
|
+
email: brentdillingham@gmail.com
|
24
|
+
executables:
|
25
|
+
- gitploy
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.markdown
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- README.markdown
|
33
|
+
- Rakefile
|
34
|
+
- VERSION
|
35
|
+
- bin/gitploy
|
36
|
+
- gitploy.gemspec
|
37
|
+
- lib/gitploy.rb
|
38
|
+
- lib/gitploy/script.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/brentd/gitploy
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Deployment DSL created with git in mind
|
73
|
+
test_files: []
|
74
|
+
|