version_bump/github_api

Minimal GitHub REST client used by the GitHub publish plugin.

Pure request-building and URL-parsing helpers are separated from the effectful create_release, which actually performs the HTTP call. This keeps the parsing/serialisation logic unit-testable without a network.

Values

pub fn build_release_payload(
  tag: String,
  name: String,
  body: String,
  prerelease: Bool,
  target: String,
) -> String

Serialise the JSON body for a create-release request.

PURE: the POST payload for api.github.com/repos/{owner}/{repo}/releases.

pub fn create_release(
  token: String,
  owner: String,
  repo: String,
  tag: String,
  name: String,
  body: String,
  prerelease: Bool,
  target: String,
) -> task.Task(Result(release.Release, error.ReleaseError))

Create a GitHub release and return the resulting Release, asynchronously.

The HTTP send is cross-target via send: on Erlang it uses httpc synchronously; on JavaScript it uses fetch (a real promise). Both yield a Task(#(status, body)), which is mapped here into a Release (parsing html_url), a non-2xx NetworkError, or a transport NetworkError (signalled as status 0).

pub fn parse_repo_url(
  url: String,
) -> Result(#(String, String), error.ReleaseError)

Extract (owner, repo) from an HTTPS or git@ GitHub remote URL.

PURE. Handles the common forms:

  • https://github.com/owner/repo.git
  • https://github.com/owner/repo
  • git@github.com:owner/repo.git
  • ssh://git@github.com/owner/repo.git The trailing .git and any trailing slash are stripped.
Search Document