Skip to content

GitHub Provider

The GitHub provider supports checking for updates from GitHub repositories.

Usage

zig
const updater = @import("updater");

const result = try updater.checkForUpdates(allocator, .{
    .provider = updater.providers.github,
    .owner = "muhammad-fiaz",
    .repo = "updater.zig",
    .current_version = "0.0.1",
});

Quick Check

zig
const result = try updater.checkGitHub(
    allocator,
    "muhammad-fiaz",
    "updater.zig",
    "0.0.1",
);

API Endpoint

The GitHub provider uses the GitHub REST API:

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

Response Parsing

The provider extracts:

FieldSource
tagtag_name
urlhtml_url
namename
bodybody
download_urlassets[0].browser_download_url
prereleaseprerelease
published_atpublished_at

Authentication

For private repositories or higher rate limits:

zig
const result = try updater.checkForUpdates(allocator, .{
    .provider = updater.providers.github,
    .owner = "username",
    .repo = "private-repo",
    .current_version = "1.0.0",
    .auth_token = "ghp_xxxxxxxxxxxx",
});

Rate Limits

  • Unauthenticated: 60 requests/hour
  • Authenticated: 5,000 requests/hour

The provider returns error.RateLimited when limits are exceeded.

Example with Auto-Update

zig
var auto_updater = updater.AutoUpdater.init(allocator, .{
    .provider = updater.providers.github,
    .owner = "muhammad-fiaz",
    .repo = "updater.zig",
    .current_version = "0.0.1",
    .auto_update = .{
        .enabled = true,
        .auto_download = true,
        .install_command = "zig build install",
    },
});
defer auto_updater.deinit();

const result = try auto_updater.checkAndUpdate();

Releases vs Tags

The GitHub provider uses the Releases API, not Tags. Ensure you create proper GitHub Releases, not just git tags.

Testing

zig
test "github provider" {
    const allocator = std.testing.allocator;
    try std.testing.expectEqualStrings("github", updater.providers.github.name);
}

Released under the MIT License.