Skip to content

Commit 92923a9

Browse files
committed
Make the the short git SHA available within the program
1 parent 3f23e07 commit 92923a9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: ./.github/actions/install
2929

3030
- name: zig build
31-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64
31+
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
3232

3333
- name: Rename binary
3434
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
@@ -60,7 +60,7 @@ jobs:
6060
arch: ${{env.ARCH}}
6161

6262
- name: zig build
63-
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8
63+
run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }})
6464

6565
- name: Rename binary
6666
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}

build.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ pub fn build(b: *std.Build) !void {
5858
.optimize = mode,
5959
});
6060
try common(b, exe, options);
61+
{
62+
var opt = b.addOptions();
63+
opt.addOption(
64+
[]const u8,
65+
"git_commit",
66+
b.option([]const u8, "git_commit", "Current git commit") orelse "dev",
67+
);
68+
exe.root_module.addImport("build_info", opt.createModule());
69+
}
6170
b.installArtifact(exe);
6271

6372
// run

0 commit comments

Comments
 (0)