Class: Homebrew::DevCmd::PrUpload Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/pr-upload.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/pr_upload.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::PrUpload::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/pr_upload.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.



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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'dev-cmd/pr-upload.rb', line 44

def run
  json_files = Dir["*.bottle.json"]
  odie "No bottle JSON files found in the current working directory" if json_files.blank?

  Homebrew.install_bundler_gems!(groups: ["pr_upload"])

  bottles_hash = bottles_hash_from_json_files(json_files, args)

  unless args.upload_only?
    bottle_args = ["bottle", "--merge", "--write"]
    bottle_args << "--verbose" if args.verbose?
    bottle_args << "--debug" if args.debug?
    bottle_args << "--keep-old" if args.keep_old?
    bottle_args << "--root-url=#{args.root_url}" if args.root_url
    bottle_args << "--committer=#{args.committer}" if args.committer
    bottle_args << "--no-commit" if args.no_commit?
    bottle_args << "--root-url-using=#{args.root_url_using}" if args.root_url_using
    bottle_args += json_files

    if args.dry_run?
      dry_run_service = if github_packages?(bottles_hash)
        # GitHub Packages has its own --dry-run handling.
        nil
      elsif github_releases?(bottles_hash)
        "GitHub Releases"
      else
        odie "Service specified by root_url is not recognized"
      end

      if dry_run_service
        puts <<~EOS
          brew #{bottle_args.join " "}
          Upload bottles described by these JSON files to #{dry_run_service}:
            #{json_files.join("\n  ")}
        EOS
        return
      end
    end

    check_bottled_formulae!(bottles_hash)

    safe_system HOMEBREW_BREW_FILE, *bottle_args

    json_files = Dir["*.bottle.json"]
    if json_files.blank?
      puts "No bottle JSON files after merge, no upload needed!"
      return
    end

    # Reload the JSON files (in case `brew bottle --merge` generated
    # `all: $SHA256` bottles)
    bottles_hash = bottles_hash_from_json_files(json_files, args)

    # Check the bottle commits did not break `brew audit`
    unless args.no_commit?
      audit_args = ["audit", "--skip-style"]
      audit_args << "--verbose" if args.verbose?
      audit_args << "--debug" if args.debug?
      audit_args += bottles_hash.keys
      safe_system HOMEBREW_BREW_FILE, *audit_args
    end
  end

  if github_releases?(bottles_hash)
    github_releases = GitHubReleases.new
    github_releases.upload_bottles(bottles_hash)
  elsif github_packages?(bottles_hash)
    github_packages = GitHubPackages.new
    github_packages.upload_bottles(bottles_hash,
                                   keep_old:      args.keep_old?,
                                   dry_run:       args.dry_run?,
                                   warn_on_error: args.warn_on_upload_failure?)
  else
    odie "Service specified by root_url is not recognized"
  end
end