forked from trashpanda001/docker-alpine-sshd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push
executable file
·30 lines (24 loc) · 880 Bytes
/
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
#!/usr/bin/env ruby
repo='sickp/alpine-sshd'
def error(message)
puts message
puts "Usage: #{__FILE__} {major}.{minor} [latest]"
exit 1
end
def execute(cmd)
puts "=> #{cmd}"
system(cmd) || abort
end
version, *tags = ARGV
error("Bad version format: #{version}") unless version&.match?(/\A\d+\.\d+(-r\d+)?\z/)
error("Unexpected tags: #{tags.join(', ')}") unless tags.empty? || (tags.first == 'latest')
dockerfile = File.join(File.dirname(__FILE__), 'versions', version, 'Dockerfile')
error("Missing Dockerfile #{dockerfile}") unless File.file?(dockerfile)
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