pushdeploy 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pushdeploy.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) Artem Yankov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ Pushdeploy
2
+ ==========
3
+
4
+ * 1
5
+ * 2
6
+ * 3
7
+
8
+ Install
9
+ -------
10
+ $ some code
11
+ $ goeshere
12
+
13
+ Usage
14
+ -----
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # This script is launched by post-receive hook when push is completed.
5
+ # The general purpose of this script is to run bundler, migration and
6
+ # other commands that you want to launch after deployment.
7
+ #
8
+
9
+ require 'pushdeploy'
10
+
11
+ PushDeploy.new(ARGV) do
12
+ bundle
13
+ migrate
14
+ run "touch /tmp/restart.txt"
15
+ end
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ deploy_dir=/Users/yankoff/ruby/pushdeploy
3
+ read oldrev newrev refname
4
+
5
+ unset GIT_DIR && cd $deploy_dir && git --work-tree=$deploy_dir pull ./ -f
6
+ source "/Users/yankoff/.rvm/scripts/rvm"
7
+ rvm ruby-1.9.2-p136
8
+ $deploy_dir/config/auto_deploy.rb $oldrev $newrev $refname $deploy_dir
@@ -1,3 +1,3 @@
1
1
  module Pushdeploy
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/pushdeploy.rb CHANGED
@@ -0,0 +1,58 @@
1
+ class PushDeploy
2
+
3
+ EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
4
+
5
+ def initialize(args, &block)
6
+
7
+ puts 'Running auto_deploy...'
8
+
9
+ @deploy_to = args[3]
10
+
11
+ @oldrev, @newrev = args.shift, args.shift || 'HEAD'
12
+ if @oldrev == '0000000000000000000000000000000000000000'
13
+ @oldrev = EMPTY_DIR
14
+ elsif @oldrev.nil?
15
+ @oldrev = '@{-1}'
16
+ end
17
+
18
+ instance_exec(&block)
19
+
20
+ end
21
+
22
+ def bundle
23
+ return if @oldrev == '0'
24
+
25
+ return unless File.exist?('Gemfile')
26
+ if %x{git diff --name-only #{@oldrev} #{@newrev}} =~ /^Gemfile|\.gemspec$/
27
+ begin
28
+ # If Bundler in turn spawns Git, it can get confused by $GIT_DIR
29
+ git_dir = ENV.delete('GIT_DIR')
30
+ run "bundle check"
31
+ unless $?.success?
32
+ puts "Bundling..."
33
+ run "bundle | grep -v '^Using ' | grep -v ' is complete'"
34
+ end
35
+ ensure
36
+ ENV['GIT_DIR'] = git_dir
37
+ end
38
+ end
39
+ end
40
+
41
+ def run(command)
42
+ Kernel.system "#{command} >&1"
43
+ end
44
+
45
+ def migrate
46
+ return if @oldrev == '0'
47
+
48
+ schema = %x{git diff --name-status #{@oldrev} #{@newrev} -- db/schema.rb}
49
+ if schema =~ /^A/
50
+ run "bundle exec rake db:create"
51
+ end
52
+
53
+ if `git diff HEAD^`.index("db/migrate")
54
+ puts "Migrating.."
55
+ run 'bundle exec rake db:migrate RAILS_ENV="production"'
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "pushdeploy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pushdeploy"
7
+ s.version = Pushdeploy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Artem Yankov"]
10
+ s.email = ["artem.yankov@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Easy deployment after 'git push' for Ruby applications}
13
+ s.description = %q{Automatically deploys application after 'git push' and run specified commands like 'bundle install' and 'rake db:migrate'}
14
+
15
+ s.rubyforge_project = "pushdeploy"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pushdeploy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.12
5
+ version: 0.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Artem Yankov
@@ -24,11 +24,18 @@ extensions: []
24
24
  extra_rdoc_files: []
25
25
 
26
26
  files:
27
- - lib/pushdeploy/pushdeploy.rb
28
- - lib/pushdeploy/version.rb
29
- - lib/pushdeploy.rb
27
+ - .gitignore
28
+ - Gemfile
29
+ - MIT-LICENSE
30
+ - README.md
31
+ - Rakefile
30
32
  - bin/pushdeploy_create_config
31
33
  - bin/pushdeploy_install_hook
34
+ - config/after_deploy.rb
35
+ - hooks/post-receive
36
+ - lib/pushdeploy.rb
37
+ - lib/pushdeploy/version.rb
38
+ - pushdeploy.gemspec
32
39
  homepage: ""
33
40
  licenses: []
34
41
 
@@ -1,59 +0,0 @@
1
- class PushDeploy
2
-
3
- EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
4
-
5
- def initialize(args, &block)
6
-
7
- puts 'Running auto_deploy...'
8
-
9
- @deploy_to = args[3]
10
-
11
- @oldrev, @newrev = args.shift, args.shift || 'HEAD'
12
- if @oldrev == '0000000000000000000000000000000000000000'
13
- @oldrev = EMPTY_DIR
14
- elsif @oldrev.nil?
15
- @oldrev = '@{-1}'
16
- end
17
-
18
- instance_exec(&block)
19
-
20
- end
21
-
22
- def bundle
23
- return if @oldrev == '0'
24
-
25
- return unless File.exist?('Gemfile')
26
- if %x{git diff --name-only #{@oldrev} #{@newrev}} =~ /^Gemfile|\.gemspec$/
27
- begin
28
- # If Bundler in turn spawns Git, it can get confused by $GIT_DIR
29
- git_dir = ENV.delete('GIT_DIR')
30
- run "bundle check"
31
- unless $?.success?
32
- puts "Bundling..."
33
- run "bundle | grep -v '^Using ' | grep -v ' is complete'"
34
- end
35
- ensure
36
- ENV['GIT_DIR'] = git_dir
37
- end
38
- end
39
- end
40
-
41
- def run(command)
42
- Kernel.system "#{command} >&1"
43
- end
44
-
45
- def migrate
46
- return if @oldrev == '0'
47
-
48
- schema = %x{git diff --name-status #{@oldrev} #{@newrev} -- db/schema.rb}
49
- if schema =~ /^A/
50
- run "bundle exec rake db:create"
51
- end
52
-
53
- if `git diff HEAD^`.index("db/migrate")
54
- puts "Migrating.."
55
- run 'bundle exec rake db:migrate RAILS_ENV="production"'
56
- end
57
- end
58
-
59
- end