forked from kontena/kontena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
159 lines (134 loc) · 3.66 KB
/
Rakefile
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
begin
require 'dotenv'
Dotenv.load
rescue LoadError
abort "Gem 'dotenv' not installed, .env not loaded" if File.exist?('.env')
end
VERSION = File.read('./VERSION').strip
UBUNTU_IMAGE = 'kontena-ubuntu-build'
UBUNTU_REPO = ENV['UBUNTU_REPO'] || 'ubuntu'
PKG_REV = ENV['PKG_REV'] || '1'
namespace :release do
def headline(text)
puts "\e[0;33m#{text}\e[0m"
end
task :setup => [:bump_version] do
%w(agent cli server).each do |dir|
Dir.chdir(dir) do
sh("bundle install")
end
end
end
task :bump_version do
headline "Bumping version to #{VERSION}"
%w(agent cli server).each do |dir|
File.write("./#{dir}/VERSION", VERSION)
end
end
task :setup_ubuntu do
headline "Building Docker image for Ubuntu package builds ..."
sh("docker build -t #{UBUNTU_IMAGE} -f build/Dockerfile.ubuntu .")
end
task :setup_cli_omnibus do
headline "Setting up CLI omnibus..."
Dir.chdir('cli') do
sh("rake release:setup_omnibus")
end
end
task :build => [
:setup,
:build_server,
:build_agent
]
task :build_server do
headline "Starting to build kontena-server ..."
Dir.chdir('server') do
sh("bundle exec rake release:build_docker")
sh("bundle exec rake release:build_docs")
end
end
task :build_agent do
headline "Starting to build kontena-agent ..."
Dir.chdir('agent') do
sh("bundle exec rake release:build_docker")
end
end
task :build_cli do
headline "Starting to build kontena-cli ..."
Dir.chdir('cli') do
sh("bundle exec rake release:build")
end
end
task :build_cli_gem do
headline "Starting to build kontena-cli gem ..."
Dir.chdir('cli') do
sh("gem build kontena-cli.gemspec")
end
end
task :package_ubuntu => [
:setup, :setup_ubuntu, :package_ubuntu_server, :package_ubuntu_agent
]
task :package_ubuntu_cli do
Dir.chdir('cli') do
sh("rake release:build_omnibus")
end
end
task :package_ubuntu_server do
sh("docker run -it --rm -w /build/server -v #{Dir.pwd}/server/release:/build/server/release #{UBUNTU_IMAGE} rake release:build_ubuntu REV=#{PKG_REV}")
end
task :package_ubuntu_agent do
sh("docker run -it --rm -w /build/agent -v #{Dir.pwd}/agent/release:/build/agent/release #{UBUNTU_IMAGE} rake release:build_ubuntu REV=#{PKG_REV}")
end
task :push => [
:build,
:push_server,
:push_agent,
:push_cli
]
task :push_server do
headline "Starting to push kontena/server ..."
Dir.chdir('server') do
sh("bundle exec rake release:push_docker")
sh("bundle exec rake release:push_docs")
end
end
task :push_agent do
headline "Starting to push kontena/agent ..."
Dir.chdir('agent') do
sh("bundle exec rake release:push_docker")
end
end
task :push_cli do
headline "Starting to push kontena-cli ..."
Dir.chdir('cli') do
sh("bundle exec rake release:push")
end
end
task :push_gem => [:build_cli_gem, :push_cli_gem]
task :push_cli_gem do
headline "Starting to push kontena-cli gem..."
Dir.chdir('cli') do
sh("gem push kontena-cli-#{VERSION}.gem")
end
end
task :push_ubuntu => [
:package_ubuntu,
:push_ubuntu_server,
:push_ubuntu_agent
]
task :push_ubuntu_cli do
Dir.chdir('cli') do
sh("rake release:push_ubuntu REV=#{PKG_REV} REPO=#{UBUNTU_REPO}")
end
end
task :push_ubuntu_server do
Dir.chdir('server') do
sh("bundle exec rake release:push_ubuntu REV=#{PKG_REV} REPO=#{UBUNTU_REPO}")
end
end
task :push_ubuntu_agent do
Dir.chdir('agent') do
sh("bundle exec rake release:push_ubuntu REV=#{PKG_REV} REPO=#{UBUNTU_REPO}")
end
end
end