heroku_tool 0.9.1 → 0.9.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/heroku_tool/commander.rb +43 -21
- data/lib/heroku_tool/tasks/heroku.thor +27 -16
- data/lib/heroku_tool/version.rb +1 -1
- data/release_notes/__TEMPLATE__.md +4 -0
- data/release_notes/v0.9.2.md +5 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5aff0c40aebac826f0c564531114ce61762c7e1fed7ad87b281160c7b27bccd0
|
|
4
|
+
data.tar.gz: b8ff4953f2f385b49f7a25a8f276bdce0e5221f34db9a5207b3f60fb3ebe1c63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7275494d3fbd74ac696cd30394b8a7969594c6c77e2ad9aac787a1562247956a3b28de99940a6f085da2b55d99337a3a207c66b441710c0f50c2328d92055783
|
|
7
|
+
data.tar.gz: 8a49007bd74cd1b5cedf559e3d7ad0afaae2765eef98d9c25b2003e04afedb7c422052f168d2fc6e3fb4ec090beb28583fc05719c785703230a18764b9d2f9fe
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "open3"
|
|
4
|
+
require "shellwords"
|
|
5
|
+
|
|
3
6
|
module HerokuTool
|
|
4
7
|
class Commander
|
|
5
8
|
# @return [HerokuTool::HerokuTargets::HerokuTarget]
|
|
@@ -12,13 +15,21 @@ module HerokuTool
|
|
|
12
15
|
@configuration = configuration
|
|
13
16
|
end
|
|
14
17
|
|
|
18
|
+
# The deploy ref is resolved to a commit once, before anything else happens, and that commit is what gets
|
|
19
|
+
# described, pushed and recorded: checking out another branch (or fetching) while the deploy is running
|
|
20
|
+
# doesn't change what is deployed or how it is reported.
|
|
21
|
+
#
|
|
22
|
+
# @return [String, false] the revision (commit sha) that was deployed, or false if the deploy failed
|
|
15
23
|
def deploy(deploy_ref, with_maintenance:)
|
|
16
|
-
|
|
24
|
+
revision = resolve_revision(deploy_ref)
|
|
25
|
+
return false unless revision
|
|
26
|
+
|
|
27
|
+
deploy_ref_description = deploy_ref_describe(revision)
|
|
17
28
|
puts "Deploy #{deploy_ref_description} to #{target} with migrate=#{target.migrate_in_release_phase ? "(during release phase)" : migrate_outside_of_release_phase?} with_maintenance=#{with_maintenance} "
|
|
18
29
|
|
|
19
|
-
output_to_be_deployed(
|
|
30
|
+
output_to_be_deployed(revision)
|
|
20
31
|
configuration.before_deploying(self, target, deploy_ref_description)
|
|
21
|
-
successful_push = puts_and_system "git push -f #{target.git_remote} #{
|
|
32
|
+
successful_push = puts_and_system "git push -f #{target.git_remote} #{revision}:#{target.heroku_target_ref}"
|
|
22
33
|
|
|
23
34
|
return false unless successful_push
|
|
24
35
|
|
|
@@ -30,12 +41,22 @@ module HerokuTool
|
|
|
30
41
|
app_revision_env_var = configuration.app_revision_env_var
|
|
31
42
|
if app_revision_env_var && app_revision_env_var != "HEROKU_SLUG_COMMIT"
|
|
32
43
|
# HEROKU_SLUG_COMMIT is automatically set by https://devcenter.heroku.com/articles/dyno-metadata
|
|
33
|
-
puts_and_system
|
|
44
|
+
puts_and_system "heroku config:set #{app_revision_env_var}=#{Shellwords.escape(deploy_ref_description)} -a #{target.heroku_app}"
|
|
34
45
|
end
|
|
35
46
|
|
|
36
47
|
maintenance_off if with_maintenance
|
|
37
48
|
configuration.after_deploying(self, target, deploy_ref_description)
|
|
38
|
-
|
|
49
|
+
revision
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @return [String, nil] the sha of the commit that deploy_ref (or the target's deploy_ref) points at right now
|
|
53
|
+
def resolve_revision(deploy_ref = nil)
|
|
54
|
+
deploy_ref ||= target.deploy_ref
|
|
55
|
+
revision = `git rev-parse --verify --quiet #{deploy_ref}^{commit}`.strip
|
|
56
|
+
return revision unless revision.empty?
|
|
57
|
+
|
|
58
|
+
puts "❌ Can't resolve '#{deploy_ref}' to a commit"
|
|
59
|
+
nil
|
|
39
60
|
end
|
|
40
61
|
|
|
41
62
|
def maintenance_on
|
|
@@ -53,7 +74,7 @@ module HerokuTool
|
|
|
53
74
|
end
|
|
54
75
|
|
|
55
76
|
def deploy_ref_describe(deploy_ref = nil)
|
|
56
|
-
`git describe #{deploy_ref || target.deploy_ref}`.strip
|
|
77
|
+
`git describe --always #{deploy_ref || target.deploy_ref}`.strip
|
|
57
78
|
end
|
|
58
79
|
|
|
59
80
|
def output_to_be_deployed(since_deploy_ref = nil)
|
|
@@ -65,10 +86,10 @@ module HerokuTool
|
|
|
65
86
|
end
|
|
66
87
|
|
|
67
88
|
# @return [Boolean] true if the command was successful
|
|
68
|
-
def puts_and_system(cmd)
|
|
69
|
-
puts
|
|
89
|
+
def puts_and_system(cmd, *args)
|
|
90
|
+
puts([cmd, *args].join(" "))
|
|
70
91
|
puts "-------------"
|
|
71
|
-
system_with_clean_env(cmd).tap do |result|
|
|
92
|
+
system_with_clean_env(cmd, *args).tap do |result|
|
|
72
93
|
if result
|
|
73
94
|
puts "-------------"
|
|
74
95
|
else
|
|
@@ -77,30 +98,31 @@ module HerokuTool
|
|
|
77
98
|
end
|
|
78
99
|
end
|
|
79
100
|
|
|
80
|
-
def puts_and_exec(cmd)
|
|
81
|
-
puts
|
|
82
|
-
exec_with_clean_env(cmd)
|
|
101
|
+
def puts_and_exec(cmd, *args)
|
|
102
|
+
puts([cmd, *args].join(" "))
|
|
103
|
+
exec_with_clean_env(cmd, *args)
|
|
83
104
|
end
|
|
84
105
|
|
|
85
|
-
def exec_with_clean_env(cmd)
|
|
86
|
-
if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
|
87
|
-
Bundler.with_unbundled_env {
|
|
106
|
+
def exec_with_clean_env(cmd, *args)
|
|
107
|
+
output, _status = if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
|
108
|
+
Bundler.with_unbundled_env { Open3.capture2(cmd, *args) }
|
|
88
109
|
elsif defined?(Bundler)
|
|
89
|
-
Bundler.with_clean_env {
|
|
110
|
+
Bundler.with_clean_env { Open3.capture2(cmd, *args) }
|
|
90
111
|
else
|
|
91
|
-
|
|
112
|
+
Open3.capture2(cmd, *args)
|
|
92
113
|
end
|
|
114
|
+
output
|
|
93
115
|
end
|
|
94
116
|
|
|
95
117
|
protected
|
|
96
118
|
|
|
97
|
-
def system_with_clean_env(cmd)
|
|
119
|
+
def system_with_clean_env(cmd, *args)
|
|
98
120
|
if defined?(Bundler) && Bundler.respond_to?(:with_unbundled_env)
|
|
99
|
-
Bundler.with_unbundled_env { system
|
|
121
|
+
Bundler.with_unbundled_env { system(cmd, *args) }
|
|
100
122
|
elsif defined?(Bundler)
|
|
101
|
-
Bundler.with_clean_env { system
|
|
123
|
+
Bundler.with_clean_env { system(cmd, *args) }
|
|
102
124
|
else
|
|
103
|
-
system
|
|
125
|
+
system(cmd, *args)
|
|
104
126
|
end
|
|
105
127
|
end
|
|
106
128
|
end
|
|
@@ -135,9 +135,9 @@ class Heroku < Thor
|
|
|
135
135
|
check_deploy_ref(deploy_ref)
|
|
136
136
|
with_maintenance = options[:maintenance].nil? && migrate_outside_of_release_phase? || options[:maintenance] || false
|
|
137
137
|
deploy_ref ||= target.deploy_ref
|
|
138
|
-
|
|
139
|
-
if
|
|
140
|
-
deploy_tracking(target_name,
|
|
138
|
+
deployed_revision = commander.deploy(deploy_ref, with_maintenance: with_maintenance)
|
|
139
|
+
if deployed_revision
|
|
140
|
+
deploy_tracking(target_name, deployed_revision)
|
|
141
141
|
else
|
|
142
142
|
exit(-1)
|
|
143
143
|
end
|
|
@@ -194,24 +194,35 @@ class Heroku < Thor
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
def notify_bugsnag_of_deploy_tracking(deploy_ref:, revision:)
|
|
197
|
-
api_key = ENV["BUGSNAG_API_KEY"]
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
197
|
+
api_key = ENV["BUGSNAG_API_KEY"].presence || "API_KEY"
|
|
198
|
+
|
|
199
|
+
app_version = deploy_ref_describe(deploy_ref)
|
|
200
|
+
json_data = {
|
|
201
|
+
apiKey: api_key,
|
|
202
|
+
appVersion: app_version,
|
|
203
|
+
sourceControl: {
|
|
204
|
+
repository: target.repository,
|
|
205
|
+
revision: revision
|
|
206
|
+
},
|
|
207
|
+
releaseStage: target.trackable_release_stage
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
args = [
|
|
211
|
+
"-H", "Content-Type: application/json",
|
|
212
|
+
"-H", "apiKey: #{api_key}",
|
|
213
|
+
"-H", "appVersion: #{app_version}",
|
|
214
|
+
"-d", json_data.to_json,
|
|
215
|
+
"https://build.bugsnag.com"
|
|
216
|
+
]
|
|
217
|
+
if api_key == "API_KEY"
|
|
206
218
|
puts "\n" + ("*" * 80) + "\n"
|
|
207
|
-
|
|
208
|
-
puts command
|
|
219
|
+
puts("curl #{args.join(" ")}")
|
|
209
220
|
puts "\n" + ("*" * 80) + "\n"
|
|
210
221
|
puts "NB: can't notify unless you specify BUGSNAG_API_KEY and rerun"
|
|
211
222
|
puts " thor heroku:deploy_tracking #{target.name} #{deploy_ref}"
|
|
212
|
-
|
|
213
|
-
puts_and_system "curl -d \"#{data}\" http://notify.bugsnag.com/deploy"
|
|
223
|
+
return
|
|
214
224
|
end
|
|
225
|
+
puts_and_system("curl", *args)
|
|
215
226
|
end
|
|
216
227
|
end
|
|
217
228
|
|
data/lib/heroku_tool/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heroku_tool
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Diggins
|
|
@@ -150,6 +150,8 @@ files:
|
|
|
150
150
|
- lib/heroku_tool/tasks/db_drop_all_tables.rake
|
|
151
151
|
- lib/heroku_tool/tasks/heroku.thor
|
|
152
152
|
- lib/heroku_tool/version.rb
|
|
153
|
+
- release_notes/__TEMPLATE__.md
|
|
154
|
+
- release_notes/v0.9.2.md
|
|
153
155
|
- templates/Rakefile
|
|
154
156
|
- templates/heroku.thor
|
|
155
157
|
- templates/heroku_targets.yml
|