Module: Octokit::Client::Releases

Included in:
Octokit::Client
Defined in:
lib/octokit/client/releases.rb

Overview

Methods for the Releases API

Instance Method Summary collapse

Instance Method Details

#create_release(repo, tag_name, options = {}) ⇒ Sawyer::Resource

Create a release

Options Hash (options):

  • :target_commitish (String)

    Specifies the commitish value that determines where the Git tag is created from.

  • :name (String)

    Name for the release

  • :body (String)

    Content for release notes

  • :draft (Boolean)

    Mark this release as a draft

  • :prerelease (Boolean)

    Mark this release as a pre-release

See Also:



30
31
32
33
# File 'lib/octokit/client/releases.rb', line 30

def create_release(repo, tag_name, options = {})
  opts = options.merge(:tag_name => tag_name)
  post "#{Repository.path repo}/releases", opts
end

#delete_release(url, options = {}) ⇒ Boolean

Delete a release



64
65
66
# File 'lib/octokit/client/releases.rb', line 64

def delete_release(url, options = {})
  boolean_from_response(:delete, url, options)
end

#delete_release_asset(asset_url, options = {}) ⇒ Boolean

Delete a release asset



126
127
128
# File 'lib/octokit/client/releases.rb', line 126

def delete_release_asset(asset_url, options = {})
  boolean_from_response(:delete, asset_url, options)
end

#release(url, options = {}) ⇒ Sawyer::Resource

Get a release



40
41
42
# File 'lib/octokit/client/releases.rb', line 40

def release(url, options = {})
  get url, options
end

#release_asset(asset_url, options = {}) ⇒ Sawyer::Resource

Get a single release asset



105
106
107
# File 'lib/octokit/client/releases.rb', line 105

def release_asset(asset_url, options = {})
  get(asset_url, options)
end

#release_assets(release_url, options = {}) ⇒ Array<Sawyer::Resource>

List release assets



73
74
75
# File 'lib/octokit/client/releases.rb', line 73

def release_assets(release_url, options = {})
  paginate release(release_url).rels[:assets].href, options
end

#releases(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_releases

List releases for a repository



14
15
16
# File 'lib/octokit/client/releases.rb', line 14

def releases(repo, options = {})
  paginate "#{Repository.path repo}/releases", options
end

#update_release(url, options = {}) ⇒ Sawyer::Resource Also known as: edit_release

Update a release

Options Hash (options):

  • :target_commitish (String)

    Specifies the commitish value that determines where the Git tag is created from.

  • :name (String)

    Name for the release

  • :body (String)

    Content for release notes

  • :draft (Boolean)

    Mark this release as a draft

  • :prerelease (Boolean)

    Mark this release as a pre-release

See Also:



54
55
56
# File 'lib/octokit/client/releases.rb', line 54

def update_release(url, options = {})
  patch url, options
end

#update_release_asset(asset_url, options = {}) ⇒ Sawyer::Resource Also known as: edit_release_asset

Update a release asset

Options Hash (options):

  • :name (String)

    The name for the file

  • :label (String)

    The download text for the file

See Also:



116
117
118
# File 'lib/octokit/client/releases.rb', line 116

def update_release_asset(asset_url, options = {})
  patch(asset_url, options)
end

#upload_asset(release_url, path_or_file, options = {}) ⇒ Sawyer::Resource

Upload a release asset

Options Hash (options):

  • :content_type (String)

    The MIME type for the file to upload

  • :name (String)

    The name for the file

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/octokit/client/releases.rb', line 85

def upload_asset(release_url, path_or_file, options = {})
  file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "r+b")
  options[:content_type] ||= content_type_from_file(file)
  raise Octokit::MissingContentType.new if options[:content_type].nil?
  unless name = options[:name]
    name = File.basename(file.path)
  end
  upload_url = release(release_url).rels[:upload].href_template.expand(:name => name)

  request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
ensure
  file.close if file
end