heroku_deploy 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -52,12 +52,31 @@ or
52
52
 
53
53
  rake heroku_deploy:backup:production
54
54
 
55
- To skip the backup when deploying to staging or production run:
55
+ To skip the backup when deploying to staging or production run set backup=false:
56
56
 
57
57
  rake heroku_deploy:staging backup=false
58
58
 
59
+ To skip maintenance mode set maintenance=false:
60
+
61
+ rake heroku_deploy:production maintenance=false
62
+
63
+ You can also define before and after hooks either in your environment or an intializer or pretty much anywhere that gets loaded:
64
+
65
+ class HerokuDeploy
66
+
67
+ def before_staging_deploy
68
+ `rake asset:packager:build_all`
69
+ end
70
+
71
+ def after_production_deploy
72
+ `script/move_latest_backup_to_nas`
73
+ end
74
+
75
+ end
76
+
59
77
  ###Coming Soon
78
+ * Rails 3 compatibility
60
79
  * Prompts for credentials if you haven't entered them
61
80
  * No need to include gem "heroku" in your Gemfile
62
81
  * Better error messages if you're trying to create an existing heroku app
63
- * Before and after hooks that allow you to arbitrarily execute code before and after deploy
82
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{heroku_deploy}
8
- s.version = "0.1.10"
8
+ s.version = "0.1.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ross Hale"]
12
- s.date = %q{2010-09-20}
12
+ s.date = %q{2010-09-27}
13
13
  s.description = %q{Deploy strategy and scripts for Heroku.}
14
14
  s.email = %q{rosshale@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -98,6 +98,7 @@ class HerokuDeploy
98
98
  end
99
99
 
100
100
  def staging
101
+ before_staging_deploy
101
102
  backup staging_app unless no_backup
102
103
 
103
104
  puts "Deploying to Staging"
@@ -107,9 +108,11 @@ class HerokuDeploy
107
108
  puts ""
108
109
  puts "Staging Deployed!"
109
110
  puts ""
111
+ after_staging_deploy
110
112
  end
111
113
 
112
114
  def production
115
+ before_production_deploy
113
116
  backup production_app unless no_backup
114
117
 
115
118
  puts "Deploying to Production"
@@ -120,6 +123,7 @@ class HerokuDeploy
120
123
  puts ""
121
124
  puts "Production Deployed!"
122
125
  puts ""
126
+ after_production_deploy
123
127
  end
124
128
 
125
129
  def backup_staging
@@ -145,13 +149,7 @@ class HerokuDeploy
145
149
 
146
150
  def push_to( branch, app )
147
151
 
148
- puts "Going into maintenance mode"
149
-
150
- `heroku maintenance:on --app #{app}`
151
-
152
- print "Waiting for slug to re-compile..."
153
- wait_for_maintenance_on( app )
154
- puts ""
152
+ go_into_maintenance(app) unless no_maintenance
155
153
 
156
154
  puts "Pushing to #{app}"
157
155
 
@@ -166,12 +164,10 @@ class HerokuDeploy
166
164
 
167
165
  `heroku restart --app #{app}`
168
166
 
169
- puts "Getting out of maintenance mode"
170
-
171
- `heroku maintenance:off --app #{app}`
167
+ get_out_of_maintenance(app) unless no_maintenance
172
168
 
173
169
  print "Waiting for app to go live..."
174
- wait_for_maintenance_off(app)
170
+ wait_for_app_to_go_up(app)
175
171
  puts ""
176
172
  end
177
173
 
@@ -207,6 +203,22 @@ class HerokuDeploy
207
203
 
208
204
  end
209
205
 
206
+ def go_into_maintenance(app)
207
+ puts "Going into maintenance mode"
208
+
209
+ `heroku maintenance:on --app #{app}`
210
+
211
+ print "Waiting for slug to re-compile..."
212
+ wait_for_maintenance_on( app )
213
+ puts ""
214
+ end
215
+
216
+ def get_out_of_maintenance(app)
217
+ puts "Getting out of maintenance mode"
218
+ `heroku maintenance:off --app #{app}`
219
+ end
220
+
221
+
210
222
  def maintenance_off(app)
211
223
  HTTParty.get("http://#{app}.heroku.com").code != 422
212
224
  end
@@ -222,7 +234,7 @@ class HerokuDeploy
222
234
  HTTParty.get("http://#{app}.heroku.com").code != 200
223
235
  end
224
236
 
225
- def wait_for_maintenance_off(app)
237
+ def wait_for_app_to_go_up(app)
226
238
  while (maintenance_on(app))
227
239
  print "."
228
240
  STDOUT.flush
@@ -241,4 +253,24 @@ class HerokuDeploy
241
253
  ENV['BACKUP'] == "false" || ENV['backup'] == "false"
242
254
  end
243
255
 
256
+ def no_maintenance
257
+ ENV['MAINTENANCE'] == "false" || ENV['maintenance'] == "false"
258
+ end
259
+
260
+ def before_staging_deploy
261
+ # override this yourself wherever you like. An initializer is a good place.
262
+ end
263
+
264
+ def after_staging_deploy
265
+ # override this yourself wherever you like. An initializer is a good place.
266
+ end
267
+
268
+ def before_production_deploy
269
+ # override this yourself wherever you like. An initializer is a good place.
270
+ end
271
+
272
+ def after_production_deploy
273
+ # override this yourself wherever you like. An initializer is a good place.
274
+ end
275
+
244
276
  end
@@ -53,17 +53,22 @@ class HerokuDeployTest < Test::Unit::TestCase
53
53
  assert HTTParty
54
54
  end
55
55
 
56
- context "with backup" do
57
-
58
- should "invoke staging and backup" do
59
- mock.proxy(@heroku_deploy).backup("example-staging")
60
- @heroku_deploy.staging
61
- end
56
+ should "invoke staging and friends" do
57
+ mock.proxy(@heroku_deploy).before_staging_deploy
58
+ mock.proxy(@heroku_deploy).after_staging_deploy
59
+ mock.proxy(@heroku_deploy).go_into_maintenance("example-staging")
60
+ mock.proxy(@heroku_deploy).get_out_of_maintenance("example-staging")
61
+ mock.proxy(@heroku_deploy).backup("example-staging")
62
+ @heroku_deploy.staging
63
+ end
62
64
 
63
- should "invoke production and backup" do
64
- mock.proxy(@heroku_deploy).backup("example")
65
- @heroku_deploy.production
66
- end
65
+ should "invoke production and friends" do
66
+ mock.proxy(@heroku_deploy).before_production_deploy
67
+ mock.proxy(@heroku_deploy).after_production_deploy
68
+ mock.proxy(@heroku_deploy).go_into_maintenance("example")
69
+ mock.proxy(@heroku_deploy).get_out_of_maintenance("example")
70
+ mock.proxy(@heroku_deploy).backup("example")
71
+ @heroku_deploy.production
67
72
  end
68
73
 
69
74
  context "without backup" do
@@ -81,6 +86,22 @@ class HerokuDeployTest < Test::Unit::TestCase
81
86
  end
82
87
  end
83
88
 
89
+ context "without maintenance mode" do
90
+ should "invoke staging and skip maintenance" do
91
+ ENV['MAINTENANCE'] = "false"
92
+ dont_allow(@heroku_deploy).go_into_maintenance("example-staging")
93
+ dont_allow(@heroku_deploy).get_out_of_maintenance("example-staging")
94
+ @heroku_deploy.staging
95
+ end
96
+
97
+ should "invoke production and skip backup" do
98
+ ENV['maintenance'] = "false"
99
+ dont_allow(@heroku_deploy).go_into_maintenance("example")
100
+ dont_allow(@heroku_deploy).get_out_of_maintenance("example")
101
+ @heroku_deploy.production
102
+ end
103
+ end
104
+
84
105
  end
85
106
 
86
107
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_deploy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 10
10
- version: 0.1.10
9
+ - 11
10
+ version: 0.1.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Hale
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-20 00:00:00 -07:00
18
+ date: 2010-09-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21