diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3526542..7c6d344 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ jobs: steps: - uses: actions/checkout@v2 with: + fetch-depth: 0 submodules: true - uses: goto-bus-stop/setup-zig@v1 with: diff --git a/build.zig b/build.zig index b085874..d2b248d 100644 --- a/build.zig +++ b/build.zig @@ -43,6 +43,15 @@ pub fn build(b: *std.build.Builder) !void { b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false, ); + const version = v: { + const git_describe_untrimmed = try b.exec(&[_][]const u8{ + "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags", + }); + + break :v std.mem.trim(u8, git_describe_untrimmed, " \n\r"); + }; + exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); + const KNOWN_FOLDERS_DEFAULT_PATH = "src/known-folders/known-folders.zig"; const known_folders_path = b.option([]const u8, "known-folders", "Path to known-folders package (default: " ++ KNOWN_FOLDERS_DEFAULT_PATH ++ ")") orelse KNOWN_FOLDERS_DEFAULT_PATH; exe.addPackage(.{ .name = "known-folders", .source = .{ .path = known_folders_path } }); diff --git a/src/main.zig b/src/main.zig index 6eafe6e..65291b0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -192,7 +192,7 @@ fn parseArgs( return .exit; } if (specified.get(.version)) { - try std.io.getStdOut().writer().print("Data Version: {s}\n", .{@tagName(build_options.data_version)}); + try std.io.getStdOut().writeAll(build_options.version ++ "\n"); return .exit; } if (specified.get(.config)) {