Make the the short git SHA available within the program

This commit is contained in:
Karl Seguin
2025-02-25 08:00:36 +08:00
parent 488c7e6c27
commit d501cbf765
2 changed files with 11 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ jobs:
- uses: ./.github/actions/install
- name: zig build
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
- name: Rename binary
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
@@ -60,7 +60,7 @@ jobs:
arch: ${{env.ARCH}}
- name: zig build
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
- name: Rename binary
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}

View File

@@ -58,6 +58,15 @@ pub fn build(b: *std.Build) !void {
.optimize = mode,
});
try common(b, exe, options);
{
var opt = b.addOptions();
opt.addOption(
[]const u8,
"git_commit",
b.option([]const u8, "git_commit", "Current git commit") orelse "dev",
);
exe.root_module.addImport("build_info", opt.createModule());
}
b.installArtifact(exe);
// run