diff --git a/build.zig b/build.zig index 2e97b83..5958484 100644 --- a/build.zig +++ b/build.zig @@ -37,4 +37,15 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the cli"); run_step.dependOn(&run_cmd.step); + + // Release step + const release_step = b.step("release", "Run release script"); + const release_exe = b.addExecutable(.{ + .name = "release", + .root_source_file = b.path("scripts/release.zig"), + .target = target, + .optimize = optimize, + }); + const release_cmd = b.addRunArtifact(release_exe); + release_step.dependOn(&release_cmd.step); } diff --git a/deno.json b/deno.json index 469af8b..1ac9358 100644 --- a/deno.json +++ b/deno.json @@ -5,7 +5,7 @@ "fmt": "zig fmt . && deno fmt", "fmt:check": "zig fmt . --check && deno fmt --check", "build": "zig build -Dtarget=x86_64-windows-msvc -Doptimize=ReleaseSmall", - "release": "deno task build && zig run ./scripts/release.zig", + "release": "zig build release", "check:hash": "certutil -hashfile dist/rb-x86_64-pc-windows-msvc.zip SHA256" }, "fmt": { diff --git a/scripts/release.zig b/scripts/release.zig index 083389b..221b1ac 100644 --- a/scripts/release.zig +++ b/scripts/release.zig @@ -23,6 +23,9 @@ pub fn main() !void { // Format version.zon try formatVersionZon(allocator); + // Build the project + try buildProject(allocator); + // Create dist directory try fs.cwd().makePath("dist"); @@ -73,6 +76,17 @@ fn formatVersionZon(allocator: std.mem.Allocator) !void { _ = try child.spawnAndWait(); } +fn buildProject(allocator: std.mem.Allocator) !void { + const argv = [_][]const u8{ + "zig", + "build", + "-Dtarget=x86_64-windows-msvc", + "-Doptimize=ReleaseSmall", + }; + var child = std.process.Child.init(&argv, allocator); + _ = try child.spawnAndWait(); +} + fn compressBinary(allocator: std.mem.Allocator) !void { const argv = [_][]const u8{ "powershell",