Build-time Checking
updater.zig can perform update checks during your build process, notifying you of new versions without blocking the build.
Quick Setup
Add to your build.zig:
zig
const std = @import("std");
const updater = @import("updater");
pub fn build(b: *std.Build) void {
// ... your build setup ...
// Add update checking
updater.build_integration.addUpdateCheck(b, .{
.owner = "muhammad-fiaz",
.repo = "updater.zig",
.current_version = "0.0.1",
.provider = .github,
});
}Configuration
zig
updater.build_integration.addUpdateCheck(b, .{
.owner = "username", // Repository owner
.repo = "reponame", // Repository name
.current_version = "1.0.0", // Current version
.provider = .github, // Provider (github, gitlab, codeberg)
.show_warnings = true, // Show update notifications
});Supported Providers
| Provider | Value |
|---|---|
| GitHub | .github |
| GitLab | .gitlab |
| Codeberg | .codeberg |
Behavior
- Never fails the build (errors are warnings only)
- Automatically disabled in CI environments
- Respects
ZIG_UPDATE_CHECK_DISABLEenvironment variable - Shows update notification if new version available
Example Output
When an update is available:
----------------------------------------------------------------
UPDATE AVAILABLE
Current version: 0.0.1
Latest version: 0.1.0
Download: https://github.com/username/repo/releases/tag/v0.1.0
----------------------------------------------------------------Environment Variables
| Variable | Effect |
|---|---|
ZIG_UPDATE_CHECK_DISABLE=1 | Disables all update checks |
CI=1 | Automatically disables checks |
GITHUB_ACTIONS=1 | Automatically disables checks |
GITLAB_CI=1 | Automatically disables checks |
Custom Build Step
For more control, create a custom step:
zig
const UpdateCheckStep = updater.build_integration.UpdateCheckStep;
pub fn build(b: *std.Build) void {
const check_step = UpdateCheckStep.create(b, .{
.owner = "username",
.repo = "myproject",
.current_version = "1.0.0",
});
// Add as dependency to specific step
const build_step = b.step("build", "Build the project");
build_step.dependOn(&check_step.step);
}Disabling in CI
Update checks are automatically disabled when these environment variables are set:
CICONTINUOUS_INTEGRATIONGITHUB_ACTIONSGITLAB_CICIRCLECITRAVIS
Manual Disable
Users can disable checks with:
bash
export ZIG_UPDATE_CHECK_DISABLE=1
zig build