Skip to content
Snippets Groups Projects
Commit e9e2be94 authored by Mike McQuaid's avatar Mike McQuaid
Browse files

test-bot: autopublish existing bottles on Bintray.

parent 4f13858f
No related branches found
No related tags found
No related merge requests found
...@@ -664,11 +664,14 @@ module Homebrew ...@@ -664,11 +664,14 @@ module Homebrew
jenkins = ENV['JENKINS_HOME'] jenkins = ENV['JENKINS_HOME']
job = ENV['UPSTREAM_JOB_NAME'] job = ENV['UPSTREAM_JOB_NAME']
id = ENV['UPSTREAM_BUILD_ID'] id = ENV['UPSTREAM_BUILD_ID']
raise "Missing Jenkins variables!" unless jenkins and job and id raise "Missing Jenkins variables!" if !jenkins || !job || !id
user = ENV["BINTRAY_USER"] bintray_user = ENV["BINTRAY_USER"]
key = ENV["BINTRAY_KEY"] bintray_key = ENV["BINTRAY_KEY"]
raise "Missing Bintray variables!" unless user && key # Skip taps for now until we're using Bintray for Homebrew/homebrew
if !tap && (!bintray_user || !bintray_key)
raise "Missing BINTRAY_USER or BINTRAY_KEY variables!"
end
ARGV << '--verbose' ARGV << '--verbose'
...@@ -700,6 +703,14 @@ module Homebrew ...@@ -700,6 +703,14 @@ module Homebrew
safe_system "brew", "pull", "--clean", pull_pr safe_system "brew", "pull", "--clean", pull_pr
end end
existing_bottles = {}
Dir.glob("*.bottle*.tar.gz") do |filename|
# Skip taps for now until we're using Bintray for Homebrew/homebrew
next if tap
formula = bottle_filename_formula_name filename
existing_bottles[formula.name] = !!formula.bottle
end
ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"]
ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"]
safe_system "brew", "bottle", "--merge", "--write", *Dir["*.bottle.rb"] safe_system "brew", "bottle", "--merge", "--write", *Dir["*.bottle.rb"]
...@@ -710,19 +721,6 @@ module Homebrew ...@@ -710,19 +721,6 @@ module Homebrew
tag = pr ? "pr-#{pr}" : "testing-#{number}" tag = pr ? "pr-#{pr}" : "testing-#{number}"
safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}" safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}"
# SourceForge upload (will be removed soon)
path = "/home/frs/project/m/ma/machomebrew/Bottles/"
if tap
tap_user, tap_repo = tap.split "/"
path += "#{tap_repo}/"
end
url = "BrewTestBot,machomebrew@frs.sourceforge.net:#{path}"
rsync_args = %w[--partial --progress --human-readable --compress]
rsync_args += Dir["*.bottle*.tar.gz"] + [url]
safe_system "rsync", *rsync_args
# Bintray upload (will take over soon) # Bintray upload (will take over soon)
repo = if tap repo = if tap
tap.sub("/", "-") + "-bottles" tap.sub("/", "-") + "-bottles"
...@@ -735,22 +733,38 @@ module Homebrew ...@@ -735,22 +733,38 @@ module Homebrew
next if tap next if tap
version = BottleVersion.parse(filename).to_s version = BottleVersion.parse(filename).to_s
formula = bottle_filename_formula_name filename formula = bottle_filename_formula_name filename
existing_bottle = existing_bottles[formula.name]
repo_url = "https://api.bintray.com/packages/homebrew/#{repo}" repo_url = "https://api.bintray.com/packages/homebrew/#{repo}"
package_url = "#{repo_url}/#{formula}" package_url = "#{repo_url}/#{formula}"
unless system "curl", "--silent", "--fail", "--output", "/dev/null", package_url unless system "curl", "--silent", "--fail", "--output", "/dev/null", package_url
safe_system "curl", "--silent", "--fail", "-u#{user}:#{key}", safe_system "curl", "--silent", "--fail",
"-u#{bintray_user}:#{bintray_key}",
"-H", "Content-Type: application/json", "-H", "Content-Type: application/json",
"-d", "{\"name\":\"#{formula}\"}", repo_url "-d", "{\"name\":\"#{formula}\"}", repo_url
puts puts
end end
content_url = "https://api.bintray.com/content/homebrew/#{repo}/#{formula}/#{version}/#{filename}" content_url = "https://api.bintray.com/content/homebrew/#{repo}/#{formula}/#{version}/#{filename}"
safe_system "curl", "--silent", "--fail", "-u#{user}:#{key}", content_url += "?publish=1&override=1" if existing_bottle
"-T", filename, content_url safe_system "curl", "--silent", "--fail",
"-u#{bintray_user}:#{bintray_key}", "-T", filename, content_url
puts puts
end end
# SourceForge upload (will be removed soon)
path = "/home/frs/project/m/ma/machomebrew/Bottles/"
if tap
tap_user, tap_repo = tap.split "/"
path += "#{tap_repo}/"
end
url = "BrewTestBot,machomebrew@frs.sourceforge.net:#{path}"
rsync_args = %w[--partial --progress --human-readable --compress]
rsync_args += Dir["*.bottle*.tar.gz"] + [url]
safe_system "rsync", *rsync_args
safe_system "git", "tag", "--force", tag safe_system "git", "tag", "--force", tag
safe_system "git", "push", "--force", remote, "refs/tags/#{tag}" safe_system "git", "push", "--force", remote, "refs/tags/#{tag}"
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment