2020-04-20 10:17:42 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "cli/parser"
|
|
|
|
require "bintray"
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module_function
|
|
|
|
|
|
|
|
def pr_upload_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
|
|
|
`pr-upload` [<options>]
|
|
|
|
|
|
|
|
Apply the bottle commit and publish bottles to Bintray.
|
|
|
|
EOS
|
|
|
|
switch "--no-publish",
|
|
|
|
description: "Apply the bottle commit and upload the bottles, but don't publish them."
|
|
|
|
switch "--dry-run", "-n",
|
|
|
|
description: "Print what would be done rather than doing it."
|
|
|
|
flag "--bintray-org=",
|
|
|
|
description: "Upload to the specified Bintray organisation (default: homebrew)."
|
2020-04-20 10:31:59 -07:00
|
|
|
flag "--root-url=",
|
|
|
|
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
|
2020-06-22 00:21:22 +10:00
|
|
|
switch :verbose
|
|
|
|
switch :debug
|
2020-04-20 10:17:42 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def pr_upload
|
|
|
|
pr_upload_args.parse
|
|
|
|
|
|
|
|
bintray_org = args.bintray_org || "homebrew"
|
|
|
|
bintray = Bintray.new(org: bintray_org)
|
|
|
|
|
2020-04-20 10:31:59 -07:00
|
|
|
bottle_args = ["bottle", "--merge", "--write"]
|
2020-06-22 00:21:22 +10:00
|
|
|
bottle_args << "--verbose" if args.verbose?
|
|
|
|
bottle_args << "--debug" if args.debug?
|
2020-04-20 10:31:59 -07:00
|
|
|
bottle_args << "--root-url=#{args.root_url}" if args.root_url
|
|
|
|
odie "No JSON files found in the current working directory" if Dir["*.json"].empty?
|
|
|
|
bottle_args += Dir["*.json"]
|
|
|
|
|
2020-04-20 10:17:42 +02:00
|
|
|
if args.dry_run?
|
2020-04-20 10:31:59 -07:00
|
|
|
puts "brew #{bottle_args.join " "}"
|
2020-04-20 10:17:42 +02:00
|
|
|
else
|
2020-04-20 15:16:08 -07:00
|
|
|
system HOMEBREW_BREW_FILE, *bottle_args
|
2020-04-20 10:17:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if args.dry_run?
|
|
|
|
puts "Upload bottles described by these JSON files to Bintray:\n #{Dir["*.json"].join("\n ")}"
|
|
|
|
else
|
|
|
|
bintray.upload_bottle_json Dir["*.json"], publish_package: !args.no_publish?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|