Merge pull request #7925 from dawidd6/dev-cmd-bottle

dev-cmd: add dispatch-build-bottle command
This commit is contained in:
Dawid Dziurla 2020-10-12 10:33:43 +02:00 committed by GitHub
commit ffe7f2a8da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,64 @@
# frozen_string_literal: true
require "cli/parser"
require "utils/github"
module Homebrew
module_function
def dispatch_build_bottle_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`dispatch-build-bottle` [<options>] <formula> [<formula> ...]
Build bottles for these formulae with GitHub Actions.
EOS
flag "--tap=",
description: "Target tap repository (default: `homebrew/core`)."
flag "--issue=",
description: "If specified, post a comment to this issue number if the job fails."
flag "--macos=",
description: "Version of macOS the bottle should be built for."
flag "--workflow=",
description: "Dispatch specified workflow (default: `dispatch-build-bottle.yml`)."
switch "--upload",
description: "Upload built bottles to Bintray."
end
end
def dispatch_build_bottle
args = dispatch_build_bottle_args.parse
raise FormulaUnspecifiedError if args.named.empty?
odie "Must specify --macos option" unless args.macos
macos = begin
MacOS::Version.from_symbol(args.macos.to_sym)
rescue MacOSVersionError
MacOS::Version.new(args.macos)
end
tap = Tap.fetch(args.tap || CoreTap.instance.name)
user, repo = tap.full_name.split("/")
workflow = args.workflow || "dispatch-build-bottle.yml"
ref = "master"
args.named.to_resolved_formulae.each do |formula|
# Required inputs
inputs = {
formula: formula.name,
macos: macos.to_s,
}
# Optional inputs
# These cannot be passed as nil to GitHub API
inputs[:issue] = args.issue if args.issue
inputs[:upload] = args.upload?.to_s if args.upload?
ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for macOS #{macos}"
GitHub.workflow_dispatch_event(user, repo, workflow, ref, inputs)
end
end
end

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "Homebrew.dispatch_build_bottle_args" do
it_behaves_like "parseable arguments"
end

View File

@ -27,6 +27,7 @@ configure
create create
deps deps
desc desc
dispatch-build-bottle
diy diy
doctor doctor
dr dr

View File

@ -968,6 +968,21 @@ a simple example. For the complete API, see:
* `-f`, `--force`: * `-f`, `--force`:
Ignore errors for disallowed formula names and named that shadow aliases. Ignore errors for disallowed formula names and named that shadow aliases.
### `dispatch-build-bottle` [*`options`*] *`formula`* [*`formula`* ...]
Build bottles for these formulae with GitHub Actions.
* `--tap`:
Target tap repository (default: `homebrew/core`).
* `--issue`:
If specified, post a comment to this issue number if the job fails.
* `--macos`:
Version of macOS the bottle should be built for.
* `--workflow`:
Dispatch specified workflow (default: `dispatch-build-bottle.yml`).
* `--upload`:
Upload built bottles to Bintray.
### `diy` [*`options`*] ### `diy` [*`options`*]
Automatically determine the installation prefix for non-Homebrew software. Automatically determine the installation prefix for non-Homebrew software.

View File

@ -1363,6 +1363,29 @@ Generate the new formula within the given tap, specified as \fIuser\fR\fB/\fR\fI
\fB\-f\fR, \fB\-\-force\fR \fB\-f\fR, \fB\-\-force\fR
Ignore errors for disallowed formula names and named that shadow aliases\. Ignore errors for disallowed formula names and named that shadow aliases\.
. .
.SS "\fBdispatch\-build\-bottle\fR [\fIoptions\fR] \fIformula\fR [\fIformula\fR \.\.\.]"
Build bottles for these formulae with GitHub Actions\.
.
.TP
\fB\-\-tap\fR
Target tap repository (default: \fBhomebrew/core\fR)\.
.
.TP
\fB\-\-issue\fR
If specified, post a comment to this issue number if the job fails\.
.
.TP
\fB\-\-macos\fR
Version of macOS the bottle should be built for\.
.
.TP
\fB\-\-workflow\fR
Dispatch specified workflow (default: \fBdispatch\-build\-bottle\.yml\fR)\.
.
.TP
\fB\-\-upload\fR
Upload built bottles to Bintray\.
.
.SS "\fBdiy\fR [\fIoptions\fR]" .SS "\fBdiy\fR [\fIoptions\fR]"
Automatically determine the installation prefix for non\-Homebrew software\. Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew\'s prefix with \fBbrew link\fR\. Automatically determine the installation prefix for non\-Homebrew software\. Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew\'s prefix with \fBbrew link\fR\.
. .