Class: Homebrew::DevCmd::DispatchBuildBottle Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/dispatch-build-bottle.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::DispatchBuildBottle::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/dispatch_build_bottle.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'dev-cmd/dispatch-build-bottle.rb', line 42

def run
  tap = Tap.fetch(args.tap || CoreTap.instance.name)
  user, repo = tap.full_name.split("/")
  ref = "master"
  workflow = args.workflow || "dispatch-build-bottle.yml"

  runners = []

  if (macos = args.macos&.compact_blank) && macos.present?
    runners += macos.map do |element|
      # We accept runner name syntax (11-arm64) or bottle syntax (arm64_big_sur)
      os, arch = element.then do |s|
        tag = Utils::Bottles::Tag.from_symbol(s.to_sym)
        [tag.to_macos_version, tag.arch]
      rescue ArgumentError, MacOSVersion::Error
        os, arch = s.split("-", 2)
        [MacOSVersion.new(os), arch&.to_sym]
      end

      if arch.present? && arch != :x86_64
        "#{os}-#{arch}"
      else
        os.to_s
      end
    end
  end

  if args.linux?
    runners << "ubuntu-22.04"
  elsif args.linux_self_hosted?
    runners << "linux-self-hosted-1"
  end

  runners << "ubuntu-22.04-arm" if args.linux_arm64?

  if runners.empty?
    raise UsageError, "Must specify `--macos`, `--linux`, `--linux-arm64`, or `--linux-self-hosted` option."
  end

  args.named.to_resolved_formulae.each do |formula|
    # Required inputs
    inputs = {
      runner:  runners.join(","),
      formula: formula.name,
    }

    # Optional inputs
    # These cannot be passed as nil to GitHub API
    inputs[:timeout] = args.timeout if args.timeout
    inputs[:issue] = args.issue if args.issue
    inputs[:upload] = args.upload?

    ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for #{runners.join(", ")}"
    GitHub.workflow_dispatch_event(user, repo, workflow, ref, **inputs)
  end
end