Build Integration API
Build-time update checking integration for build.zig.
Types
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,
};
};UpdateCheckStep
Build step for checking updates.
zig
pub const UpdateCheckStep = struct {
step: std.Build.Step,
config: BuildConfig,
allocator: std.mem.Allocator,
pub fn create(b: *std.Build, config: BuildConfig) *UpdateCheckStep;
};Functions
addUpdateCheck
Add update checking to a build.
zig
pub fn addUpdateCheck(b: *std.Build, config: BuildConfig) void;Parameters
b: The build instanceconfig: Update check configuration
Behavior
- Adds a step to the default build that checks for updates
- Logs a warning if an update is available
- Never fails the build
- Automatically skipped in CI environments
Example
zig
const std = @import("std");
const updater = @import("updater");
pub fn build(b: *std.Build) void {
updater.build_integration.addUpdateCheck(b, .{
.owner = "username",
.repo = "myproject",
.current_version = "1.0.0",
.provider = .github,
});
// ... rest of build
}Output
When an update is available:
┌────────────────────────────────────────────────────────────────┐
│ UPDATE AVAILABLE │
│ │
│ Current version: 1.0.0 │
│ Latest version: 2.0.0 │
│ │
│ Download: https://github.com/username/repo/releases/v2.0.0 │
└────────────────────────────────────────────────────────────────┘Automatic Disabling
Build-time checks are skipped when:
ZIG_UPDATE_CHECK_DISABLEenvironment variable is set- Any of these CI environment variables are detected:
CICONTINUOUS_INTEGRATIONGITHUB_ACTIONSGITLAB_CICIRCLECITRAVIS
Error Handling
Network errors are logged as warnings but never fail the build:
warning: [updater.zig] Update check failed: ConnectionFailed