paratrooper 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/mattpolito/paratrooper.png?branch=master)](https://travis-ci.org/mattpolito/paratrooper)
5
5
  [![Code Climate](https://codeclimate.com/github/mattpolito/paratrooper.png)](https://codeclimate.com/github/mattpolito/paratrooper)
6
6
 
7
- Make your complex deploy to [Heroku][] easy.
7
+ Make your complex deploy to [Heroku][] easy. This library affords you the ability to make a quick and concise deployment rake task.
8
8
 
9
9
  ## Installation
10
10
 
@@ -60,6 +60,27 @@ Paratrooper::Deploy.new('app')
60
60
  Paratrooper::Deploy.new('app')
61
61
  ```
62
62
 
63
+ ## Tag Management
64
+
65
+ By providing tag options into Paratrooper, your code can be tagged and deployed from different reference points.
66
+
67
+ ### Staging example
68
+ ```ruby
69
+ Paratrooper::Deploy.new("staging-app",
70
+ tag: 'staging'
71
+ )
72
+ ```
73
+ This will create/update a `staging` git tag at `HEAD`
74
+
75
+ ### Production example
76
+ ```ruby
77
+ Paratrooper::Deploy.new("amazing-production-app",
78
+ tag: 'production'
79
+ match_tag_to: 'staging'
80
+ )
81
+ ```
82
+ This will create/update a `production` git tag at `staging` and deploys the `production` tag
83
+
63
84
  ## Sensible Default Deployment
64
85
 
65
86
  You can use the objects methods any way you'd like but we've provided a sensible default at `Paratrooper#deploy`
@@ -74,31 +95,67 @@ This will perform the following tasks:
74
95
  * Deactivate maintenance mode
75
96
  * Warm application instance
76
97
 
77
- ## Example Usage
78
-
98
+ ### Example Usage
79
99
  ```ruby
80
100
  require 'paratrooper'
81
101
 
82
102
  namespace :deploy do
83
103
  desc 'Deploy app in staging environment'
84
104
  task :staging do
85
- deployment = Paratrooper::Deploy.new("amazing-staging-app", tag: 'staging')
105
+ deployment = Paratrooper::Deploy.new("amazing-staging-app",
106
+ tag: 'staging'
107
+ )
86
108
 
87
109
  deployment.deploy
88
110
  end
89
111
 
90
112
  desc 'Deploy app in production environment'
91
113
  task :production do
92
- deployment = Paratrooper::Deploy.new("amazing-production-app", tag: 'production')
114
+ Paratrooper::Deploy.new("amazing-production-app",
115
+ tag: 'production'
116
+ match_tag_to: 'staging'
117
+ )
93
118
 
94
119
  deployment.deploy
95
120
  end
96
121
  end
97
122
  ```
98
123
 
124
+ ## Bucking the Norm
125
+
126
+ Our default deploy gets us most of the way but maybe it's not for you. We've got you covered. Once you've instantated Paratrooper, you have access to all of the included methods as well as any arbitrary code that needs to be run.
127
+
128
+ Say you want to let [New Relic][] know that you are deploying. That way your heartbeat notifications will not make you crazy with false downtime.
129
+
130
+ ### Example Usage
131
+ ```ruby
132
+ require 'paratrooper'
133
+
134
+ namespace :deploy do
135
+ desc 'Deploy app in production environment'
136
+ task :production do
137
+ Paratrooper::Deploy.new("amazing-production-app",
138
+ tag: 'production'
139
+ match_tag_to: 'staging'
140
+ )
141
+
142
+ %x[curl https://heroku.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/disable -X POST -H "X-Api-Key: API_KEY"]
143
+
144
+ deployment.activate_maintenance_mode
145
+ deployment.update_repo_tag
146
+ deployment.push_repo
147
+ deployment.run_migrations
148
+ deployment.app_restart
149
+ deployment.deactivate_maintenance_mode
150
+ deployment.warm_instance
151
+
152
+ %x[curl https://heroku.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/enable -X POST -H "X-Api-Key: API_KEY"]
153
+ end
154
+ end
155
+ ```
156
+
99
157
  ## Nice to haves
100
158
 
101
- * deploy to heroku from tags
102
159
  * send [New Relic][] a notification to toggle heartbeat during deploy
103
160
 
104
161
  ## Contributing
@@ -5,14 +5,14 @@ require 'paratrooper/system_caller'
5
5
  module Paratrooper
6
6
  class Deploy
7
7
  attr_reader :app_name, :formatter, :system_caller, :heroku, :tag_name,
8
- :deploy_tag
8
+ :match_tag
9
9
 
10
10
  def initialize(app_name, options = {})
11
11
  @app_name = app_name
12
12
  @formatter = options[:formatter] || DefaultFormatter.new
13
13
  @heroku = options[:heroku] || HerokuWrapper.new(app_name, options)
14
14
  @tag_name = options[:tag]
15
- @deploy_tag = options[:deploy_tag] || 'master'
15
+ @match_tag = options[:match_tag_to] || 'master'
16
16
  @system_caller = options[:system_caller] || SystemCaller.new
17
17
  end
18
18
 
@@ -29,14 +29,15 @@ module Paratrooper
29
29
  def update_repo_tag
30
30
  unless tag_name.nil? || tag_name.empty?
31
31
  notify_screen("Updating Repo Tag: #{tag_name}")
32
- system_call "git tag #{tag_name} #{deploy_tag} -f"
32
+ system_call "git tag #{tag_name} #{match_tag} -f"
33
33
  system_call "git push origin #{tag_name}"
34
34
  end
35
35
  end
36
36
 
37
37
  def push_repo
38
- notify_screen("Pushing #{deploy_tag} to Heroku")
39
- system_call "git push -f #{git_remote} #{deploy_tag}:master"
38
+ reference_point = tag_name || 'master'
39
+ notify_screen("Pushing #{reference_point} to Heroku")
40
+ system_call "git push -f #{git_remote} #{reference_point}:master"
40
41
  end
41
42
 
42
43
  def run_migrations
@@ -1,3 +1,3 @@
1
1
  module Paratrooper
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -107,7 +107,7 @@ describe Paratrooper::Deploy do
107
107
 
108
108
  context "when deploy_tag is available" do
109
109
  before do
110
- options.merge!(deploy_tag: 'deploy_this')
110
+ options.merge!(match_tag_to: 'deploy_this')
111
111
  end
112
112
 
113
113
  it 'creates a git tag at deploy_tag reference point' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paratrooper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: