mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
build: automate version resolution in build.zig
Removes manual git flags from CI and build scripts. Versioning is now automatically derived from git and build.zig.zon. With this PR, we follow https://semver.org/ Logic: 1. Read the version from build.zig.zon 2. If it doesn't have a `.pre` field (i.e. dev/alpha/beta) it will use that 3. Otherwise it will get the info from git: hash and number of commits since last `.0` version 4. Then build the version: `0.3.0-dev.1493+0896edc3` Note that, since the latest stable version is `0.2.6`. The convention is to use `0.3.0-dev`, as: - `0.2.6` < `0.3.0.dev` < `0.3.0`
This commit is contained in:
@@ -47,7 +47,7 @@ pub noinline fn crash(
|
||||
writer.print("\nreason: {s}\n", .{reason}) catch abort();
|
||||
writer.print("OS: {s}\n", .{@tagName(builtin.os.tag)}) catch abort();
|
||||
writer.print("mode: {s}\n", .{@tagName(builtin.mode)}) catch abort();
|
||||
writer.print("version: {s}\n", .{lp.build_config.git_commit}) catch abort();
|
||||
writer.print("version: {s}\n", .{lp.build_config.version}) catch abort();
|
||||
inline for (@typeInfo(@TypeOf(args)).@"struct".fields) |f| {
|
||||
writer.writeAll(f.name ++ ": ") catch break;
|
||||
@import("log.zig").writeValue(.pretty, @field(args, f.name), writer) catch abort();
|
||||
@@ -86,7 +86,7 @@ fn report(reason: []const u8, begin_addr: usize, args: anytype) !void {
|
||||
var url_buffer: [4096]u8 = undefined;
|
||||
const url = blk: {
|
||||
var writer: std.Io.Writer = .fixed(&url_buffer);
|
||||
try writer.print("https://crash.lightpanda.io/c?v={s}&r=", .{lp.build_config.git_commit});
|
||||
try writer.print("https://crash.lightpanda.io/c?v={s}&r=", .{lp.build_config.version});
|
||||
for (reason) |b| {
|
||||
switch (b) {
|
||||
'A'...'Z', 'a'...'z', '0'...'9', '-', '.', '_' => try writer.writeByte(b),
|
||||
|
||||
@@ -59,11 +59,8 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
|
||||
return std.process.cleanExit();
|
||||
},
|
||||
.version => {
|
||||
if (lp.build_config.git_version) |version| {
|
||||
std.debug.print("{s} ({s})\n", .{ version, lp.build_config.git_commit });
|
||||
} else {
|
||||
std.debug.print("{s}\n", .{lp.build_config.git_commit});
|
||||
}
|
||||
var stdout = std.fs.File.stdout().writer(&.{});
|
||||
try stdout.interface.print("{s}\n", .{lp.build_config.version});
|
||||
return std.process.cleanExit();
|
||||
},
|
||||
else => {},
|
||||
|
||||
@@ -145,7 +145,7 @@ const LightPandaEvent = struct {
|
||||
try writer.write(builtin.cpu.arch);
|
||||
|
||||
try writer.objectField("version");
|
||||
try writer.write(build_config.git_version orelse build_config.git_commit);
|
||||
try writer.write(build_config.version);
|
||||
|
||||
try writer.objectField("event");
|
||||
try writer.write(@tagName(std.meta.activeTag(self.event)));
|
||||
|
||||
Reference in New Issue
Block a user