brew/Library/Homebrew/dev-cmd/pr-publish.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2020-03-22 13:12:48 +11:00
# frozen_string_literal: true
require "cli/parser"
require "utils/github"
module Homebrew
module_function
def pr_publish_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`pr-publish` [<options>] <pull_request> [<pull_request> ...]
2020-03-22 13:12:48 +11:00
Publish bottles for a pull request with GitHub Actions.
Requires write access to the `homebrew/core` repository.
2020-03-22 13:12:48 +11:00
EOS
switch :verbose
min_named 1
2020-03-22 13:12:48 +11:00
end
end
def pr_publish
pr_publish_args.parse
2020-03-31 10:02:29 +02:00
ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" unless OS.mac?
args.named.uniq.each do |arg|
2020-03-22 13:12:48 +11:00
arg = "#{CoreTap.instance.default_remote}/pull/#{arg}" if arg.to_i.positive?
url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX
_, user, repo, issue = *url_match
odie "Not a GitHub pull request: #{arg}" unless issue
tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX)
2020-03-22 13:12:48 +11:00
ohai "Dispatching #{tap} pull request ##{issue}"
2020-03-24 12:31:58 +11:00
GitHub.dispatch_event(user, repo, "Publish ##{issue}", pull_request: issue)
2020-03-22 13:12:48 +11:00
end
end
end