git-deploy 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,20 @@
1
1
  Easy git deployment
2
2
  ===================
3
3
 
4
- Straightforward, [Heroku][]-style, push-based deployment. Your deploys will look like this:
4
+ Straightforward, [Heroku][]-style, push-based deployment. Your deploys can become as simple as this:
5
5
 
6
6
  $ git push production master
7
7
 
8
8
  To get started, install the "git-deploy" gem.
9
9
 
10
- $ gem install git-deploy
10
+ gem install git-deploy
11
11
 
12
+ Only the person who is setting up deployment for the first time needs to install
13
+ the gem. You don't have to add it to your project's Gemfile.
12
14
 
13
- What application frameworks/languages are supported?
14
- ----------------------------------------------------
15
+
16
+ Which app languages/frameworks are supported?
17
+ ---------------------------------------------
15
18
 
16
19
  Regardless of the fact that this tool is mostly written in Ruby, git-deploy can be useful for any kind of code that needs deploying on a remote server. The default scripts are suited for Ruby web apps, but can be edited to accommodate other frameworks.
17
20
 
@@ -20,50 +23,63 @@ Your deployment is customized with per-project callback scripts which can be wri
20
23
  The assumption is that you're deploying to a single host to which you connect over SSH using public/private key authentication.
21
24
 
22
25
 
23
- Setup steps
24
- -----------
26
+ Initial setup
27
+ -------------
25
28
 
26
29
  1. Create a git remote for where you'll push the code on your server. The name of this remote in the examples is "production", but it can be whatever you wish ("online", "website", or other).
27
-
28
- $ git remote add production user@example.com:/path/to/myapp
29
-
30
- The "/path/to/myapp" is the directory where your code will reside. It doesn't have to exist; it will be created for you during this setup.
30
+
31
+ ```sh
32
+ git remote add production "user@example.com:/apps/mynewapp"
33
+ ```
34
+
35
+ `/apps/mynewapp` is the directory where you want your code to reside on the
36
+ remote server. If the directory doesn't exist, the next step creates it.
31
37
 
32
38
  2. Run the setup task:
33
-
34
- $ git deploy setup -r production
35
-
36
- This will initialize the remote git repository in the target directory ("/path/to/myapp" in the above example) and install the remote git hooks.
39
+
40
+ ```sh
41
+ git deploy setup -r "production"
42
+ ```
43
+
44
+ This will initialize the remote git repository in the deploy directory
45
+ (`/apps/mynewapp` in the above example) and install the remote git hook.
37
46
 
38
47
  3. Run the init task:
39
-
40
- $ git deploy init
41
-
42
- This generates default deploy callback scripts in the "deploy/" directory. You must check them in version control. They are going to be executed on the server on each deploy.
48
+
49
+ ```sh
50
+ git deploy init
51
+ ```
52
+
53
+ This generates default deploy callback scripts in the `deploy/` directory.
54
+ You should check them in git because they are going to be executed on the
55
+ server during each deploy.
43
56
 
44
57
  4. Push the code.
45
58
 
46
- $ git push production master
59
+ ```sh
60
+ git push production master
61
+ ```
47
62
 
48
63
  3. Login to your server and manually perform necessary one-time administrative operations. This might include:
49
64
  * set up the Apache/nginx virtual host for this application;
50
- * check your "config/database.yml" and create the production database.
51
-
65
+ * check your `config/database.yml` and create the production database.
52
66
 
53
- Deployment
54
- ----------
55
67
 
56
- If you've set your app correctly, visiting "http://example.com" in your browser should show it up and running.
68
+ Everyday deployments
69
+ --------------------
57
70
 
58
- Now, subsequent deployments are done simply by pushing to the branch that is currently checked out on the remote:
71
+ If you've set your app correctly, visiting <http://example.com> in your browser
72
+ should show it up and running.
59
73
 
60
- $ git push production master
74
+ Now, subsequent deployments are done simply **by pushing to the branch that is
75
+ currently checked out on the remote**:
61
76
 
62
- Because the deployments are done with git, not everyone on the team had to install git-deploy. Just the person who was doing the setup.
77
+ git push production master
63
78
 
64
- Deployments are logged to "log/deploy.log" in your application.
79
+ Because the deployments are performed with git, nobody else on the team needs to
80
+ install the "git-deploy" gem.
65
81
 
66
- On every deploy, the "deploy/after_push" script performs the following:
82
+ On every deploy, the default `deploy/after_push` script performs the following:
67
83
 
68
84
  1. updates git submodules (if there are any);
69
85
  2. runs `bundle install --deployment` if there is a Gemfile;
@@ -71,16 +87,30 @@ On every deploy, the "deploy/after_push" script performs the following:
71
87
  4. clears cached CSS/JS assets in "public/stylesheets" and "public/javascripts";
72
88
  5. restarts the web application.
73
89
 
74
- You can customize all of this by editing scripts in the "deploy/" directory of your app.
90
+ You can customize all this by editing generated scripts in the `deploy/`
91
+ directory of your app.
92
+
93
+ Deployments are logged to `log/deploy.log` in your application's directory.
94
+
75
95
 
76
96
  How it works
77
97
  ------------
78
98
 
79
- The "setup" task installed a "post-receive" hook in the remote git repository. This is how your working copy on the server is kept up to date. This hook, after checking out latest code, asynchronously dispatches to "deploy/after_push" script in your application. This script executes on the server and also calls "deploy/before_restart", "restart", and "after_restart" callbacks if they are present.
99
+ The `git deploy setup` command installed a `post-receive` git hook in the remote
100
+ repository. This is how your code on the server is kept up to date. This script
101
+ checks out the latest version of your project from the current branch and
102
+ runs the following callback scripts:
103
+
104
+ * `deploy/after_push` - on subsequent pushes. It in turn executes:
105
+ * `deploy/before_restart`
106
+ * `deploy/restart`
107
+ * `deploy/after_restart`
80
108
 
81
- These scripts are ordinary unix executable files. The ones which are generated for you are written in shell script and Ruby.
109
+ All of the callbacks are optional. These scripts are ordinary Unix executables.
110
+ The ones which get generated for you by `git deploy init` are written in shell
111
+ script and Ruby.
82
112
 
83
113
  It's worth remembering that "after_push" is done **asynchronously from your git push**. This is because migrating the database and updating submodules might take a long time and you don't want to wait for all that during a git push. But, this means that when the push is done, the server has *not yet restarted*. You might need to wait a few seconds or a minute.
84
114
 
85
115
 
86
- [heroku]: http://heroku.com/
116
+ [heroku]: http://heroku.com/
@@ -55,7 +55,7 @@ class GitDeploy < Thor
55
55
 
56
56
  desc "restart", "Restarts the application on the server"
57
57
  def restart
58
- run "cd #{deploy_to} && deploy/restart | tee -a log/deploy.log"
58
+ run "cd #{deploy_to} && deploy/restart 2>&1 | tee -a log/deploy.log"
59
59
  end
60
60
 
61
61
  desc "rollback", "Rolls back the checkout to before the last push"
@@ -83,15 +83,3 @@ class GitDeploy < Thor
83
83
  }
84
84
  end
85
85
  end
86
-
87
- __END__
88
- Multiple hosts:
89
- # deploy:
90
- invoke :code
91
- command = ["cd #{deploy_to}"]
92
- command << ".git/hooks/post-reset `cat .git/ORIG_HEAD` HEAD 2>&1 | tee -a log/deploy.log"
93
-
94
- # code:
95
- command = ["cd #{deploy_to}"]
96
- command << source.scm('fetch', remote, "+refs/heads/#{branch}:refs/remotes/origin/#{branch}")
97
- command << source.scm('reset', '--hard', "origin/#{branch}")
@@ -34,7 +34,9 @@ class GitDeploy
34
34
  end
35
35
 
36
36
  def remote_urls(remote)
37
- git_config["config --get-all remote.#{remote}.url"].to_s.split("\n")
37
+ git_config["remote -v"].to_s.split("\n").
38
+ select {|l| l =~ /^#{remote}\t/ }.
39
+ map {|l| l.split("\t")[1].sub(/\(.+?\)$/, '') }
38
40
  end
39
41
 
40
42
  def remote_url(remote = options[:remote])
@@ -11,7 +11,7 @@ echo files changed: $(git diff $oldrev $newrev --diff-filter=ACDMR --name-only |
11
11
 
12
12
  umask 002
13
13
 
14
- git submodule init && git submodule sync && git submodule update
14
+ git submodule sync && git submodule update --init --recursive
15
15
 
16
16
  run deploy/before_restart
17
17
  run deploy/restart && run deploy/after_restart
@@ -42,11 +42,11 @@ if [ -z "${oldrev//0}" ]; then
42
42
  chmod 0664 $logfile $restart
43
43
 
44
44
  # init submodules
45
- git submodule update --init | tee -a $logfile
45
+ git submodule update --recursive --init 2>&1 | tee -a $logfile
46
46
  else
47
47
  # log timestamp
48
48
  echo ==== $(date) ==== >> $logfile
49
49
 
50
50
  # execute the deploy hook in background
51
- [ -x deploy/after_push ] && nohup deploy/after_push $oldrev $newrev 1>>$logfile 2>>$logfile &
51
+ [ -x deploy/after_push ] && (nohup deploy/after_push $oldrev $newrev 1>>$logfile 2>>$logfile &)
52
52
  fi
@@ -1,4 +1,4 @@
1
- require 'rspec'
1
+ require 'rspec/autorun'
2
2
  require 'git_deploy/configuration'
3
3
 
4
4
  describe GitDeploy::Configuration do
@@ -22,7 +22,7 @@ describe GitDeploy::Configuration do
22
22
  end
23
23
 
24
24
  def stub_remote_url(url, remote = options[:remote])
25
- stub_git_config("config --get-all remote.#{remote}.url", url)
25
+ stub_git_config("remote -v", "#{remote}\t#{url} (fetch)")
26
26
  end
27
27
 
28
28
  describe "extracting user/host from remote url" do
metadata CHANGED
@@ -1,49 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
5
4
  prerelease:
5
+ version: 0.5.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mislav Marohnić
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-03 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ prerelease: false
16
+ type: :runtime
17
+ version_requirements: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.14.6
15
23
  name: thor
16
- requirement: &70233531184120 !ruby/object:Gem::Requirement
24
+ requirement: !ruby/object:Gem::Requirement
17
25
  none: false
18
26
  requirements:
19
- - - ! '>='
27
+ - - '='
20
28
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70233531184120
29
+ version: 0.14.6
25
30
  - !ruby/object:Gem::Dependency
31
+ prerelease: false
32
+ type: :runtime
33
+ version_requirements: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 2.6.6
26
39
  name: net-ssh
27
- requirement: &70233531200000 !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
28
41
  none: false
29
42
  requirements:
30
- - - ! '>='
43
+ - - ~>
31
44
  - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70233531200000
45
+ version: 2.6.6
36
46
  - !ruby/object:Gem::Dependency
47
+ prerelease: false
48
+ type: :runtime
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
37
55
  name: net-scp
38
- requirement: &70233531199500 !ruby/object:Gem::Requirement
56
+ requirement: !ruby/object:Gem::Requirement
39
57
  none: false
40
58
  requirements:
41
- - - ! '>='
59
+ - - ~>
42
60
  - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70233531199500
61
+ version: 1.1.0
47
62
  description: A tool to install useful git hooks on your remote repository to enable
48
63
  push-based, Heroku-like deployment on your host.
49
64
  email: mislav.marohnic@gmail.com
@@ -65,7 +80,8 @@ files:
65
80
  - README.markdown
66
81
  - LICENSE
67
82
  homepage: https://github.com/mislav/git-deploy
68
- licenses: []
83
+ licenses:
84
+ - MIT
69
85
  post_install_message:
70
86
  rdoc_options: []
71
87
  require_paths:
@@ -84,9 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
100
  version: '0'
85
101
  requirements: []
86
102
  rubyforge_project:
87
- rubygems_version: 1.8.12
103
+ rubygems_version: 1.8.23
88
104
  signing_key:
89
105
  specification_version: 3
90
106
  summary: Simple git push-based application deployment
91
107
  test_files: []
92
- has_rdoc: