Class: GitHubReleases Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Context, Utils::Curl
Defined in:
github_releases.rb

Overview

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.

GitHub Releases client.

Constant Summary collapse

URL_REGEX =

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

%r{https://github\.com/([\w-]+)/([\w-]+)?/releases/download/(.+)}.freeze

Instance Method Summary collapse

Methods included from Utils::Curl

curl, curl_args, curl_check_http_content, curl_download, curl_executable, curl_http_content_headers_and_checksum, curl_output, curl_with_workarounds, http_status_ok?, parse_headers, url_protected_by_cloudflare?, url_protected_by_incapsula?

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Instance Method Details

#upload_bottles(bottles_hash) ⇒ void

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.

Parameters:

  • bottles_hash (Hash{String => T.untyped})


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'github_releases.rb', line 19

def upload_bottles(bottles_hash)
  bottles_hash.each_value do |bottle_hash|
    root_url = bottle_hash["bottle"]["root_url"]
    url_match = root_url.match URL_REGEX
    _, user, repo, tag = *url_match

    # Ensure a release is created.
    release = begin
      rel = GitHub.get_release user, repo, tag
      odebug "Existing GitHub release \"#{tag}\" found"
      rel
    rescue GitHub::API::HTTPNotFoundError
      odebug "Creating new GitHub release \"#{tag}\""
      GitHub.create_or_update_release user, repo, tag
    end

    # Upload bottles as release assets.
    bottle_hash["bottle"]["tags"].each_value do |tag_hash|
      remote_file = tag_hash["filename"]
      local_file = tag_hash["local_filename"]
      odebug "Uploading #{remote_file}"
      GitHub.upload_release_asset user, repo, release["id"], local_file: local_file, remote_file: remote_file
    end
  end
end