Skip to content

Commit

Permalink
Build 10 versions in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg committed Apr 11, 2024
1 parent 088055a commit 360fd0b
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions bin/build-all-and-upload
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Packagecloud
@token = token
@packages = packages
@distributions = distributions
@lock = Mutex.new
end

def exists?(dist_name, name)
Expand All @@ -38,7 +39,7 @@ class Packagecloud
form_data = [["package[distro_version_id]", dist_id(dist_name).to_s],
["package[package_file]", file]]
request.set_form form_data, "multipart/form-data"
response = @http.request(request)
response = @lock.synchronize { @http.request(request) }
case response
when Net::HTTPCreated
package = JSON.parse(response.body)
Expand Down Expand Up @@ -92,31 +93,37 @@ github = Github.new
DISTS = %w[ubuntu/jammy ubuntu/focal].freeze
PLATFORMS = %w[amd64 arm64].freeze

to_build = []
to_build = Queue.new
github.releases do |r|
next if r["prerelease"]
next if r["draft"]
version = r["tag_name"].sub("OTP-", "")
DISTS.each do |dist|
PLATFORMS.each do |platform|
filename = "esl-erlang_#{version}-1_#{platform}.deb"
to_build << [dist, platform, version] unless packagecloud.exists? dist, filename
next if packagecloud.exists? dist, filename
to_build << p([dist, platform, version])
end
end
end

puts "Packages to build:"
pp to_build

to_build.each do |dist, platform, version|
system("depot", "build",
"--platform", "linux/#{platform}",
"--build-arg", "erlang_version=#{version}",
"--build-arg", "image=#{dist.sub('/', ':')}",
"--output", ".",
".", exception: true)
File.open("esl-erlang_#{version}-1_#{platform}.deb") do |file|
packagecloud.upload(dist, file)
File.unlink(file)
Array.new(10) do
Thread.new do
loop do
dist, platform, version = to_build.pop || break
system("depot", "build",
"--platform", "linux/#{platform}",
"--build-arg", "erlang_version=#{version}",
"--build-arg", "image=#{dist.sub('/', ':')}",
"--output", ".",
".", exception: true)
File.open("esl-erlang_#{version}-1_#{platform}.deb") do |file|
packagecloud.upload(dist, file)
File.unlink(file)
end
end
end
end

0 comments on commit 360fd0b

Please sign in to comment.