Skip to content

Configuration

Complete reference for all configuration options in updater.zig.

Build Options

Configure via zig build command line or as dependency options.

OptionTypeDefaultDescription
enable_update_checkerbooltrueMaster switch for all update checking
allow_build_time_checkbooltrueAllow build-time update checks
allow_runtime_checkbooltrueAllow runtime update checks
default_timeout_msu6410000Default HTTP timeout (milliseconds)
default_interval_secondsu6486400Default background check interval

Command Line Usage

bash
zig build \
    -Denable_update_checker=true \
    -Dallow_build_time_check=true \
    -Dallow_runtime_check=true \
    -Ddefault_timeout_ms=5000 \
    -Ddefault_interval_seconds=3600

Dependency Usage

zig
const updater_dep = b.dependency("updater", .{
    .target = target,
    .optimize = optimize,
    .enable_update_checker = true,
    .default_timeout_ms = 5000,
});

UpdateConfig

Runtime configuration for update checking.

zig
pub const UpdateConfig = struct {
    /// Enable/disable update checking
    enabled: bool = true,

    /// Run checks in background thread
    background: bool = false,

    /// Check interval for background mode (seconds)
    interval_seconds: u64 = 86400,

    /// HTTP request timeout (milliseconds)
    timeout_ms: u64 = 10000,

    /// Git provider to use
    provider: GitProvider,

    /// Repository owner/organization
    owner: []const u8,

    /// Repository name
    repo: []const u8,

    /// Current version of the application
    current_version: []const u8,

    /// Version comparator (default: semantic)
    comparator: ?VersionComparator = null,

    /// Callback for background mode
    on_update: ?*const fn (UpdateResult) void = null,

    /// Include prerelease versions
    include_prereleases: bool = false,

    /// Custom User-Agent string
    user_agent: ?[]const u8 = null,
};

Example

zig
const config = updater.UpdateConfig{
    .enabled = true,
    .background = false,
    .timeout_ms = 5000,
    .provider = updater.providers.github,
    .owner = "username",
    .repo = "project",
    .current_version = "1.0.0",
    .comparator = updater.version.semantic,
    .include_prereleases = false,
};

BuildConfig

Configuration for build-time update checking.

zig
pub const BuildConfig = struct {
    /// Repository owner (required)
    owner: []const u8,

    /// Repository name (required)
    repo: []const u8,

    /// Current version (required)
    current_version: []const u8,

    /// Provider to use
    provider: Provider = .github,

    /// Show warnings
    show_warnings: bool = true,

    pub const Provider = enum {
        github,
        gitlab,
        codeberg,
    };
};

Example

zig
updater.build_integration.addUpdateCheck(b, .{
    .owner = "username",
    .repo = "project",
    .current_version = "1.0.0",
    .provider = .github,
    .show_warnings = true,
});

Environment Variables

VariableEffect
ZIG_UPDATE_CHECK_DISABLEDisable all update checking globally
CIAuto-detect CI environment
GITHUB_ACTIONSDetect GitHub Actions
GITLAB_CIDetect GitLab CI
CIRCLECIDetect CircleCI
TRAVISDetect Travis CI
JENKINS_URLDetect Jenkins
BUILDKITEDetect Buildkite
DRONEDetect Drone
AZURE_PIPELINESDetect Azure Pipelines

Provider Configuration

Built-in Providers

zig
// GitHub
.provider = updater.providers.github,

// GitLab
.provider = updater.providers.gitlab,

// Codeberg
.provider = updater.providers.codeberg,

Self-hosted Providers

zig
// Gitea/Forgejo
.provider = updater.providers.gitea("https://git.example.com"),

// GitLab
.provider = updater.providers.selfHostedGitlab("https://gitlab.example.com"),

Custom Providers

zig
.provider = updater.providers.custom(
    "name",
    buildUrlFn,
    parseFn,
    &headers,
),

Version Comparators

zig
// Semantic versioning (X.Y.Z)
.comparator = updater.version.semantic,

// Numeric (any number of parts)
.comparator = updater.version.numeric,

// Lexical (string comparison)
.comparator = updater.version.lexical,

// Date-based (YYYY.MM.DD)
.comparator = updater.version.date_based,

// Custom
.comparator = myCustomComparator,

Timeout Recommendations

ScenarioRecommended Timeout
Fast networks3000ms
Normal networks5000-10000ms
Slow/unreliable15000-30000ms
Build-time10000ms (default)

Interval Recommendations

ScenarioRecommended Interval
Frequent updates3600s (1 hour)
Normal86400s (24 hours)
Infrequent604800s (1 week)

Next Steps

Released under the MIT License.