Skip to content

Commit

Permalink
Update Actions workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
monomycelium committed Jun 30, 2024
1 parent f4cd7df commit 270a68c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
version: 0.13.0

- name: Build
run: zig build -DReleaseFast -Dtarget=${{ matrix.TARGET }}
run: zig build -Doptimize=ReleaseFast -Dtarget=${{ matrix.TARGET }}

- name: Upload the binary
uses: svenstaro/upload-release-action@v2
Expand Down
11 changes: 9 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
Expand All @@ -21,8 +21,15 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});

// forgive the mess
const env: ?[]u8 = std.process.getEnvVarOwned(b.allocator, "RELEASE_VERSION") catch null;
defer if (env) |e| b.allocator.free(e);

const printed: []u8 = if (env) |e| try std.fmt.allocPrint(b.allocator, "rf-{s}-{s}-{s}", .{ e, @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) }) else try b.allocator.dupe(u8, "rf");
defer b.allocator.free(printed);

const exe = b.addExecutable(.{
.name = "rf",
.name = printed,
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
Expand Down

0 comments on commit 270a68c

Please sign in to comment.