GhEx.Releases (gh_ex v0.3.4)

Copy Markdown View Source

Convenience functions for the GitHub Releases REST API.

Thin wrappers over GhEx.REST that return the same {:ok, body, meta} / {:error, reason} shape; opts pass through to Req.

Summary

Functions

Creates a release. attrs is the JSON body (tag_name, name, body, draft, prerelease, ...).

Generates a release name and Markdown body without saving a release.

Gets the latest published release.

Lists releases for a repository.

Auto-paginates a repository's releases into a lazy Stream (see GhEx.REST.stream/3).

Uploads raw asset data to a release's dedicated upload endpoint.

Types

asset()

@type asset() :: %{
  :name => String.t(),
  :content_type => String.t(),
  :data => iodata(),
  optional(:label) => String.t()
}

id()

@type id() :: integer() | String.t()

Functions

create(client, owner, repo, attrs, opts \\ [])

@spec create(GhEx.Client.t(), String.t(), String.t(), map(), keyword()) ::
  GhEx.REST.result()

Creates a release. attrs is the JSON body (tag_name, name, body, draft, prerelease, ...).

delete(client, owner, repo, id, opts \\ [])

@spec delete(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Deletes a release.

generate_release_notes(client, owner, repo, attrs, opts \\ [])

@spec generate_release_notes(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  map(),
  keyword()
) ::
  GhEx.REST.result()

Generates a release name and Markdown body without saving a release.

attrs must contain tag_name and may include target_commitish, previous_tag_name, or configuration_file_path.

get(client, owner, repo, id, opts \\ [])

@spec get(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets a release by id.

get_by_tag(client, owner, repo, tag, opts \\ [])

@spec get_by_tag(GhEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Gets a release by tag name.

get_latest(client, owner, repo, opts \\ [])

@spec get_latest(GhEx.Client.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Gets the latest published release.

list(client, owner, repo, opts \\ [])

Lists releases for a repository.

stream(client, owner, repo, opts \\ [])

@spec stream(GhEx.Client.t(), String.t(), String.t(), keyword()) :: Enumerable.t()

Auto-paginates a repository's releases into a lazy Stream (see GhEx.REST.stream/3).

update(client, owner, repo, id, attrs, opts \\ [])

@spec update(GhEx.Client.t(), String.t(), String.t(), id(), map(), keyword()) ::
  GhEx.REST.result()

Updates a release.

upload_asset(client, owner, repo, release_id, asset, opts \\ [])

@spec upload_asset(GhEx.Client.t(), String.t(), String.t(), id(), asset(), keyword()) ::
  GhEx.REST.result()

Uploads raw asset data to a release's dedicated upload endpoint.

The asset map requires :name, :content_type, and raw :data; :label is optional. GitHub.com uploads use uploads.github.com, while a GitHub Enterprise Server client whose REST URL ends in /api/v3 uses /api/uploads on the same origin.

To use the hypermedia URL returned by GitHub when creating or fetching a release, pass it as upload_url: release["upload_url"]. URI-template suffixes such as {?name,label} are removed automatically.

The wrapper owns the request body, name/label query parameters, and Content-Type header. Other opts pass through to Req.