forked from Qovery/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-rollback.rb
executable file
·81 lines (61 loc) · 1.4 KB
/
release-rollback.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env ruby
# release-rollback.sh
#
# SUMMARY
#
# Rolls back a fresh release. This should only be used in situations
# where the release process failed.
require_relative "setup"
#
# Commit
#
metadata = Metadata.load!(META_ROOT, DOCS_ROOT, GUIDES_ROOT, PAGES_ROOT)
release = metadata.latest_release
version = release.version
#
# Rollback
#
input = Printer.get("Do you want to rollback #{version}?")
if input == "n"
Printer.error!("You can only rollback the latest release")
end
branch_commands =
if release.version.patch == 0
commands =
<<~EOF
git branch -d v#{version.major}.#{version.minor}
git push origin --delete v#{version.major}.#{version.minor}
EOF
commands.chomp
else
""
end
commands =
<<~EOF
git tag -d v#{version}
git push --delete origin v#{version}
#{branch_commands}
EOF
commands.chomp!
words =
<<~EOF
We'll be rolling back v#{version} with the following commands:
#{commands.indent(2)}
Proceed to execute the above commands?
EOF
if Printer.get(words, ["y", "n"]) == "n"
Printer.error!("Ok, I've aborted. Please re-run this command when you're ready.")
end
commands.chomp.split("\n").each do |command|
system(command)
if !$?.success?
Printer.error!(
<<~EOF
Command failed!
#{command}
Produced the following error:
#{$?.inspect}
EOF
)
end
end