Skip to content
Snippets Groups Projects
Unverified Commit 3095fbc8 authored by Dawid Dziurla's avatar Dawid Dziurla
Browse files

dev-cmd: add dispatch-build-bottle command

parent 0732a86a
No related branches found
No related tags found
No related merge requests found
# 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
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "Homebrew.dispatch_build_bottle_args" do
it_behaves_like "parseable arguments"
end
......@@ -27,6 +27,7 @@ configure
create
deps
desc
dispatch-build-bottle
diy
doctor
dr
......
......@@ -1008,6 +1008,21 @@ a simple example. For the complete API, see:
* `-f`, `--force`:
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`*]
Automatically determine the installation prefix for non-Homebrew software.
......
......@@ -1443,6 +1443,29 @@ Generate the new formula within the given tap, specified as \fIuser\fR\fB/\fR\fI
\fB\-f\fR, \fB\-\-force\fR
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]"
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\.
.
......
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