Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 14 additions & 0 deletions scripts/release.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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",
Expand Down