This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
push
executable file
·63 lines (56 loc) · 1.7 KB
/
push
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
#!/usr/bin/env ruby
repo='sickp/alpine-nginx'
def error(message)
puts message
puts "Usage: #{__FILE__} {major}.{minor}.{patch}-r{revision} [tag]... ]"
exit 1
end
def execute(cmd)
puts "=> #{cmd}"
system(cmd) || abort
end
version, *tags = ARGV
md = version&.match(/\A(((\d+)\.\d+)\.\d+)-r\d+\z/)
case md && md[2]
when "1.17"
puts "Pushing 1.17.x mainline..."
possible_tags = [ md[1], md[2], 'mainline', 'latest' ]
when "1.16"
puts "Pushing 1.16.x stable..."
possible_tags = [ md[1], md[2], 'stable' ]
when "1.15"
puts "Pushing 1.15.x..."
possible_tags = [ md[1], md[2] ]
when "1.14"
puts "Pushing 1.14.x..."
possible_tags = [ md[1], md[2] ]
when "1.13"
puts "Pushing 1.13.x..."
possible_tags = [ md[1], md[2] ]
when "1.12"
puts "Pushing 1.12.x..."
possible_tags = [ md[1], md[2] ]
when "1.11"
puts "Pushing 1.11.x..."
possible_tags = [ md[1], md[2] ]
when "1.10"
puts "Pushing 1.10.x..."
possible_tags = [ md[1], md[2] ]
else
error("Unknown version: #{md ? md[2] : 'missing'}")
end
dockerfile = File.join(File.dirname(__FILE__), 'versions', version, 'Dockerfile')
error("Missing Dockerfile #{dockerfile}") unless File.file?(dockerfile)
bad_tags = tags - possible_tags
puts "Possible tags: #{possible_tags.join(', ')}"
error('Must provide at least one tag.') if tags.empty?
puts "Given tags: #{tags.join(', ')}"
error("Illegal tag(s): #{bad_tags.join(', ')}") unless bad_tags.empty?
puts "==== Pushing #{repo}:#{version} ===="
execute("docker image push #{repo}:#{version}")
tags.each do |tag|
puts "==== Tagging #{repo}:#{tag} ===="
execute("docker image tag #{repo}:#{version} #{repo}:#{tag}")
execute("docker image push #{repo}:#{tag}")
execute("docker image rm #{repo}:#{tag}")
end