Skip to content

Providers API

Built-in Git hosting providers and factory functions.

Built-in Providers

github

GitHub API provider.

zig
pub const github: GitProvider;

API endpoint: https://api.github.com/repos/{owner}/{repo}/releases/latest

Headers:

  • Accept: application/vnd.github+json
  • User-Agent: updater.zig/0.0.1
  • X-GitHub-Api-Version: 2022-11-28

gitlab

GitLab API provider.

zig
pub const gitlab: GitProvider;

API endpoint: https://gitlab.com/api/v4/projects/{owner}%2F{repo}/releases/permalink/latest

Headers:

  • Accept: application/json
  • User-Agent: updater.zig/0.0.1

codeberg

Codeberg (Gitea) API provider.

zig
pub const codeberg: GitProvider;

API endpoint: https://codeberg.org/api/v1/repos/{owner}/{repo}/releases/latest

Headers:

  • Accept: application/json
  • User-Agent: updater.zig/0.0.1

Factory Functions

gitea

Create a provider for self-hosted Gitea/Forgejo instances.

zig
pub fn gitea(base_url: []const u8) GitProvider;

Parameters

  • base_url: Base URL of the Gitea instance (e.g., https://git.example.com)

Returns

A GitProvider configured for the specified Gitea instance.

Example

zig
const myGitea = updater.providers.gitea("https://git.mycompany.com");

selfHostedGitlab

Create a provider for self-hosted GitLab instances.

zig
pub fn selfHostedGitlab(base_url: []const u8) GitProvider;

Parameters

  • base_url: Base URL of the GitLab instance (e.g., https://gitlab.example.com)

Returns

A GitProvider configured for the specified GitLab instance.

Example

zig
const myGitlab = updater.providers.selfHostedGitlab("https://gitlab.mycompany.com");

custom

Create a fully custom provider.

zig
pub fn custom(
    name: []const u8,
    build_url_fn: *const fn (std.mem.Allocator, []const u8, []const u8) std.mem.Allocator.Error![]const u8,
    parse_fn: *const fn (std.mem.Allocator, []const u8) GitProvider.ParseError!ReleaseInfo,
    headers: []const HttpHeader,
) GitProvider;

Parameters

  • name: Human-readable provider name
  • build_url_fn: Function to build the API URL
  • parse_fn: Function to parse the API response
  • headers: HTTP headers to include in requests

Returns

A fully custom GitProvider.

Example

zig
const myProvider = updater.providers.custom(
    "my-git-server",
    myBuildUrl,
    myParseResponse,
    &myHeaders,
);

Provider Comparison

ProviderAPI VersionAuth SupportPrerelease Field
GitHubv3 RESTBearer tokenprerelease
GitLabv4 RESTPrivate-Tokenupcoming_release
Codebergv1 RESTBearer tokenprerelease
Giteav1 RESTBearer tokenprerelease

Response Formats

GitHub Response

json
{
  "tag_name": "v1.0.0",
  "html_url": "https://github.com/owner/repo/releases/v1.0.0",
  "name": "Release 1.0.0",
  "body": "Release notes...",
  "published_at": "2024-01-15T12:00:00Z",
  "prerelease": false,
  "draft": false
}

GitLab Response

json
{
  "tag_name": "v1.0.0",
  "name": "Release 1.0.0",
  "description": "Release notes...",
  "released_at": "2024-01-15T12:00:00Z",
  "upcoming_release": false,
  "_links": {
    "self": "https://gitlab.com/owner/repo/-/releases/v1.0.0"
  }
}

Gitea/Codeberg Response

json
{
  "tag_name": "v1.0.0",
  "html_url": "https://codeberg.org/owner/repo/releases/tag/v1.0.0",
  "name": "Release 1.0.0",
  "body": "Release notes...",
  "published_at": "2024-01-15T12:00:00Z",
  "prerelease": false,
  "draft": false
}

Released under the MIT License.