Provider Overview
updater.zig supports multiple Git hosting providers with a consistent API.
Built-in Providers
| Provider | Type | API |
|---|---|---|
| GitHub | Cloud | REST API v3 |
| GitLab | Cloud | REST API v4 |
| Codeberg | Cloud | Gitea API v1 |
| Self-hosted | On-premise | Various |
| Custom | User-defined | Any |
Provider Comparison
| Feature | GitHub | GitLab | Codeberg | Gitea | Custom |
|---|---|---|---|---|---|
| Rate limiting | Yes | Yes | Yes | Varies | N/A |
| Auth required | No* | No* | No* | Varies | N/A |
| Prerelease support | Yes | Yes | Yes | Yes | Custom |
| Draft support | Yes | No | Yes | Yes | Custom |
*Auth required for private repositories
Quick Usage
zig
const updater = @import("updater");
// Use built-in providers
const github_result = try updater.checkGitHub(allocator, "owner", "repo", "1.0.0");
const gitlab_result = try updater.checkGitLab(allocator, "owner", "repo", "1.0.0");
const codeberg_result = try updater.checkCodeberg(allocator, "owner", "repo", "1.0.0");
// Use self-hosted providers
const myGitea = updater.providers.gitea("https://git.example.com");
const myGitlab = updater.providers.selfHostedGitlab("https://gitlab.example.com");
// Use fully custom provider
const myProvider = updater.providers.custom("custom", buildFn, parseFn, &headers);API Endpoints
GitHub
GET https://api.github.com/repos/{owner}/{repo}/releases/latestGitLab
GET https://gitlab.com/api/v4/projects/{owner}%2F{repo}/releases/permalink/latestCodeberg/Gitea
GET https://codeberg.org/api/v1/repos/{owner}/{repo}/releases/latestAuthentication
For private repositories, add authentication headers:
GitHub
zig
.{ .name = "Authorization", .value = "Bearer YOUR_TOKEN" }GitLab
zig
.{ .name = "PRIVATE-TOKEN", .value = "YOUR_TOKEN" }Gitea/Codeberg
zig
.{ .name = "Authorization", .value = "token YOUR_TOKEN" }Error Handling
All providers handle common HTTP errors:
| Status | Meaning | Handling |
|---|---|---|
| 200 | Success | Parse response |
| 401 | Unauthorized | Return error |
| 403 | Forbidden | Return error (may be rate limit) |
| 404 | Not found | Return error |
| 429 | Rate limited | Return error |
| 5xx | Server error | Return error |