version_bump/forgejo_api
Minimal Forgejo REST client used by the Forgejo publish plugin.
Forgejo (the software Codeberg runs) exposes a Gitea-compatible REST API
whose create-release endpoint mirrors GitHub’s almost field-for-field. The
key differences from github_api: the base URL is instance-dependent
(Forgejo is self-hostable), and authentication uses the token scheme.
Pure request-building 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 {base}/api/v1/repos/{owner}/{repo}/releases.
pub fn create_release(
base_url: String,
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 Forgejo 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 release_endpoint(
base_url: String,
owner: String,
repo: String,
) -> String
Build the create-release endpoint URL from the instance base URL.
PURE. base_url is the root of the Forgejo instance (e.g.
https://codeberg.org or https://git.example.com:3000); trailing slashes
are tolerated.