geordi 0.12.0 → 0.12.1
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/bin/deploy-to-production +49 -15
- data/lib/geordi/version.rb +1 -1
- metadata +4 -4
data/bin/deploy-to-production
CHANGED
@@ -1,21 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
def
|
4
|
-
|
3
|
+
def color_code(color_name, background_color_name = nil)
|
4
|
+
colors = %w[ black red green yellow blue pink cyan white ].map(&:to_sym)
|
5
|
+
color = 30 + colors.index(color_name)
|
6
|
+
if background_code = colors.index(background_color_name)
|
7
|
+
background = 40 + background_code
|
8
|
+
bold = 1
|
9
|
+
end
|
10
|
+
[ bold, color, background ].compact.join ';'
|
5
11
|
end
|
6
12
|
|
7
|
-
def colorize(text,
|
13
|
+
def colorize(text, color_name, background_color_name = nil)
|
14
|
+
color_code = color_code(color_name, background_color_name)
|
8
15
|
"\e[#{color_code}m#{text}\e[0m"
|
9
16
|
end
|
10
17
|
|
11
|
-
def
|
12
|
-
colorize(text,
|
18
|
+
def header(text)
|
19
|
+
puts colorize(text, :yellow, :blue), ''
|
13
20
|
end
|
14
21
|
|
15
|
-
def call_or_fail(command)
|
16
|
-
puts
|
17
|
-
|
18
|
-
|
22
|
+
def call_or_fail(command, return_output = false)
|
23
|
+
puts colorize(command, :pink), ''
|
24
|
+
if return_output
|
25
|
+
result = `#{command}`.to_s.strip
|
26
|
+
$?.success? or raise "Error while calling #{command}: #{$?}"
|
27
|
+
else
|
28
|
+
result = system(command) or raise "Error while calling #{command}: #{$?}"
|
29
|
+
puts
|
30
|
+
end
|
19
31
|
result
|
20
32
|
end
|
21
33
|
|
@@ -31,26 +43,48 @@ def prompt(message, default)
|
|
31
43
|
input
|
32
44
|
end
|
33
45
|
|
46
|
+
def success(message)
|
47
|
+
puts colorize(message, :green), ''
|
48
|
+
exit 0
|
49
|
+
end
|
50
|
+
|
51
|
+
def error(message)
|
52
|
+
puts colorize(message, :red), ''
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
34
56
|
puts
|
35
57
|
|
58
|
+
ENV['PAGER'] = 'cat'
|
59
|
+
|
36
60
|
master_branch = prompt('master branch', 'master')
|
37
61
|
production_branch = prompt('production branch', 'production')
|
38
62
|
production_stage = prompt('production capistrano stage', 'production')
|
39
63
|
|
64
|
+
header("Checking if your #{master_branch} is up to date")
|
65
|
+
|
66
|
+
diff_size = call_or_fail("git fetch && git diff #{master_branch} origin/#{master_branch} | wc -l", true)
|
67
|
+
changes_size = call_or_fail("git status -s | wc -l", true)
|
68
|
+
|
69
|
+
if diff_size == '0' and changes_size == '0'
|
70
|
+
puts "All good.", ''
|
71
|
+
else
|
72
|
+
error "Your #{master_branch} is not the same as on origin or holds uncommitted changes. Fix that first."
|
73
|
+
end
|
74
|
+
|
40
75
|
header("Checking what's on #{production_stage} right now...")
|
41
76
|
|
42
77
|
call_or_fail("git checkout #{production_branch} && git pull")
|
43
78
|
|
44
79
|
header("You are about to deploy the following commits from #{master_branch} to #{production_branch}:")
|
45
80
|
|
46
|
-
|
47
|
-
|
48
|
-
call_or_fail("git log #{production_branch}..#{master_branch}")
|
81
|
+
call_or_fail("git log #{production_branch}..#{master_branch} --oneline")
|
49
82
|
|
50
|
-
if prompt("Go ahead with the deployment? (y/n)", "n") == 'y'
|
83
|
+
if prompt("Go ahead with the deployment? (y/n)", "n").downcase == 'y'
|
51
84
|
puts("git merge #{master_branch} && git push && cap #{production_stage} deploy:migrations")
|
52
85
|
call_or_fail("git merge #{master_branch} && git push && cap #{production_stage} deploy:migrations")
|
53
|
-
|
86
|
+
success 'Deployment complete.'
|
54
87
|
else
|
55
|
-
|
88
|
+
error 'Deployment cancelled.'
|
56
89
|
end
|
90
|
+
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 45
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 12
|
9
|
-
-
|
10
|
-
version: 0.12.
|
9
|
+
- 1
|
10
|
+
version: 0.12.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-16 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|