Commit 5d7aadc

Eric Bower  ·  2026-05-09 11:03:56 -0400 EDT
parent 7ef2be4
feat: pico.sh ci integration
3 files changed,  +21, -25
M build.zig
+2, -10
 1@@ -16,16 +16,8 @@ pub fn build(b: *std.Build) void {
 2     const version = b.option([]const u8, "version", "Version string for release") orelse
 3         @as([]const u8, @import("build.zig.zon").version);
 4 
 5-    var code: u8 = 0;
 6-    const git_sha = std.mem.trim(u8, b.runAllowFail(
 7-        &.{ "git", "rev-parse", "--short", "HEAD" },
 8-        &code,
 9-        .Inherit,
10-    ) catch "unknown", "\n");
11-
12     const options = b.addOptions();
13     options.addOption([]const u8, "version", version);
14-    options.addOption([]const u8, "git_sha", git_sha);
15     const ghostty_ver = @import("build.zig.zon").dependencies.ghostty.hash;
16     options.addOption([]const u8, "ghostty_version", ghostty_ver);
17 
18@@ -139,14 +131,14 @@ pub fn build(b: *std.Build) void {
19             const arch_name = @tagName(release_target.cpu_arch orelse .x86_64);
20             const tarball_name = b.fmt("zmx-{s}-{s}-{s}.tar.gz", .{ version, os_name, arch_name });
21 
22-            const tar = b.addSystemCommand(&.{ "tar", "--no-xattrs", "-czf" });
23+            const tar = b.addSystemCommand(&.{ "tar", "-czf" });
24 
25             const tarball = tar.addOutputFileArg(tarball_name);
26             tar.addArg("-C");
27             tar.addDirectoryArg(release_exe.getEmittedBinDirectory());
28             tar.addArg("zmx");
29 
30-            const shasum = b.addSystemCommand(&.{ "shasum", "-a", "256" });
31+            const shasum = b.addSystemCommand(&.{"sha256sum"});
32             shasum.addFileArg(tarball);
33             const shasum_output = shasum.captureStdOut();
34 
M pico.sh
+18, -8
 1@@ -1,16 +1,26 @@
 2 #!/usr/bin/env bash
 3-set -xeo pipefail
 4+set -euo pipefail
 5 
 6-# This is a little experiement seeing how we could use zmx as a job engine for CI
 7+export ZMX_SESSION_PREFIX="${ZMX_SESSION_PREFIX:-ci.zmx.}"
 8+EVENT_TYPE="${PICO_CI_EVENT_TYPE:-manual}"
 9 
10-export ZMX_SESSION_PREFIX="ci-"
11+echo "running ci event=${EVENT_TYPE} session=${ZMX_SESSION_PREFIX}"
12 
13-zmx run build podman build -t zig .
14+zmx run build docker build -t zig-zmx .
15+zmx run fmt -d docker run --rm -it -v "$(pwd)":/app zig-zmx zig fmt --check .
16+zmx run test -d docker run --rm -it -v "$(pwd)":/app zig-zmx zig build test
17+zmx run integration -d docker run --rm -it -v "$(pwd)":/app zig-zmx zig build test-integration
18+zmx wait "*"
19+
20+if [[ $EVENT_TYPE != "release" ]]; then
21+  echo "success!"
22+  exit 0
23+fi
24 
25-zmx run fmt -d podman run --rm -it -v "$(pwd)":/app zig zig fmt --check .
26-zmx run test -d podman run --rm -it -v "$(pwd)":/app zig zig build test --summary all
27-zmx run integration -d podman run --rm -it -v "$(pwd)":/app zig zig build test-integration
28+NEW_VERSION="0.6.0"
29+zmx run semver sed -i "s/\.version = \"[^\"]*\"/.version = \"$NEW_VERSION\"/" build.zig.zon && cat build.zig.zon
30+zmx run build-release -d docker run --rm -it -v "$(pwd)":/app zig-zmx zig build release
31+# zmx run upload -d docker run --rm -it -v "$(pwd)":/app -v ~/.ssh:/root/.ssh:ro zig-zmx zig build upload
32 zmx wait "*"
33 
34-zmx kill "*"
35 echo "success!"
M src/main.zig
+1, -7
 1@@ -1,6 +1,5 @@
 2 const std = @import("std");
 3 const posix = std.posix;
 4-const builtin = @import("builtin");
 5 const build_options = @import("build_options");
 6 const ghostty_vt = @import("ghostty-vt");
 7 const ipc = @import("ipc.zig");
 8@@ -11,7 +10,6 @@ const cross = @import("cross.zig");
 9 const socket = @import("socket.zig");
10 
11 pub const version = build_options.version;
12-pub const git_sha = build_options.git_sha;
13 pub const ghostty_version = build_options.ghostty_version;
14 
15 var log_system = log.LogSystem{};
16@@ -1202,13 +1200,9 @@ const Daemon = struct {
17 fn printVersion(cfg: *Cfg) !void {
18     var buf: [256]u8 = undefined;
19     var w = std.fs.File.stdout().writer(&buf);
20-    var ver = version;
21-    if (builtin.mode == .Debug) {
22-        ver = git_sha;
23-    }
24     try w.interface.print(
25         "zmx\t\t{s}\nghostty_vt\t{s}\nsocket_dir\t{s}\nlog_dir\t\t{s}\n",
26-        .{ ver, ghostty_version, cfg.socket_dir, cfg.log_dir },
27+        .{ version, ghostty_version, cfg.socket_dir, cfg.log_dir },
28     );
29     try w.interface.flush();
30 }