@@ -109,6 +109,87 @@ jobs:
109109 cp -R "$RELEASE_DIR/binaries" "$BUNDLE_DIR/binaries"
110110 fi
111111
112+ - name : Install Zig (0.15.2)
113+ run : |
114+ set -euo pipefail
115+ ZIG_VERSION="0.15.2"
116+
117+ HOST_ARCH="$(uname -m)"
118+ if [ "$HOST_ARCH" = "arm64" ] || [ "$HOST_ARCH" = "aarch64" ]; then
119+ ZIG_ARCH="aarch64"
120+ elif [ "$HOST_ARCH" = "x86_64" ] || [ "$HOST_ARCH" = "amd64" ]; then
121+ ZIG_ARCH="x86_64"
122+ else
123+ echo "Unsupported host arch: $HOST_ARCH"
124+ exit 1
125+ fi
126+
127+ URL="https://ziglang.org/download/${ZIG_VERSION}/zig-macos-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
128+ curl -fsSL "$URL" -o "$RUNNER_TEMP/zig.tar.xz"
129+ mkdir -p "$RUNNER_TEMP/zig"
130+ tar -xf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig"
131+
132+ ZIG_BIN="$(find "$RUNNER_TEMP/zig" -maxdepth 2 -type f -name zig | head -n 1)"
133+ if [ -z "$ZIG_BIN" ]; then
134+ echo "Failed to locate zig binary after extracting."
135+ exit 1
136+ fi
137+
138+ echo "$(dirname "$ZIG_BIN")" >> "$GITHUB_PATH"
139+ zig version
140+
141+ - name : Build Ghostty VT dylib (universal)
142+ run : |
143+ set -euo pipefail
144+
145+ VENDOR_DIR="apps/macos/vendor/ghostty"
146+ BRIDGE_DIR="apps/macos/Experiments/GhosttyVTBridge"
147+ OUT_DIR="apps/macos/App/GhosttyVT/ghostty/lib"
148+ OUT_LIB="$OUT_DIR/libhack_ghostty_vt.dylib"
149+
150+ if [ ! -d "$VENDOR_DIR" ]; then
151+ echo "Missing vendor ghostty dir: $VENDOR_DIR"
152+ exit 1
153+ fi
154+
155+ mkdir -p "$OUT_DIR"
156+
157+ # Patch Ghostty's lib_vt.zig for our C ABI bridge.
158+ python3 - <<'PY'
159+ import pathlib
160+
161+ lib_vt = pathlib.Path("apps/macos/vendor/ghostty/src/lib_vt.zig")
162+ text = lib_vt.read_text(encoding="utf-8")
163+ guard = 'if (@import("root") == lib) {'
164+ patched = 'if (@import("root") == lib and terminal.options.c_abi) {'
165+ if guard in text and patched not in text:
166+ text = text.replace(guard, patched)
167+ if "@export(&" in text:
168+ text = text.replace("@export(&", "@export(")
169+ lib_vt.write_text(text, encoding="utf-8")
170+ PY
171+
172+ mkdir -p "$RUNNER_TEMP/ghosttyvt/arm64" "$RUNNER_TEMP/ghosttyvt/x86_64"
173+
174+ pushd "$BRIDGE_DIR" >/dev/null
175+ GHOSTTY_DIR="$GITHUB_WORKSPACE/$VENDOR_DIR"
176+
177+ zig build -Dghostty="$GHOSTTY_DIR" -Doptimize=ReleaseSafe -Dtarget=aarch64-macos --prefix "$RUNNER_TEMP/ghosttyvt/arm64"
178+ zig build -Dghostty="$GHOSTTY_DIR" -Doptimize=ReleaseSafe -Dtarget=x86_64-macos --prefix "$RUNNER_TEMP/ghosttyvt/x86_64"
179+ popd >/dev/null
180+
181+ ARM_LIB="$RUNNER_TEMP/ghosttyvt/arm64/lib/libhack_ghostty_vt.dylib"
182+ X64_LIB="$RUNNER_TEMP/ghosttyvt/x86_64/lib/libhack_ghostty_vt.dylib"
183+
184+ if [ ! -f "$ARM_LIB" ] || [ ! -f "$X64_LIB" ]; then
185+ echo "Missing built libs: $ARM_LIB / $X64_LIB"
186+ ls -la "$RUNNER_TEMP/ghosttyvt/arm64/lib" || true
187+ ls -la "$RUNNER_TEMP/ghosttyvt/x86_64/lib" || true
188+ exit 1
189+ fi
190+
191+ lipo -create "$ARM_LIB" "$X64_LIB" -output "$OUT_LIB"
192+
112193 - name : Install xcodegen
113194 run : brew install xcodegen
114195
@@ -185,6 +266,23 @@ jobs:
185266
186267 codesign -vvv "$BUNDLED_HACK"
187268
269+ - name : Codesign Ghostty VT dylib
270+ env :
271+ GHOSTTY_VT : apps/macos/App/GhosttyVT/ghostty/lib/libhack_ghostty_vt.dylib
272+ run : |
273+ set -euo pipefail
274+ if [ ! -f "$GHOSTTY_VT" ]; then
275+ echo "Missing Ghostty VT dylib: $GHOSTTY_VT"
276+ exit 1
277+ fi
278+
279+ codesign --force --options runtime --timestamp \
280+ --sign "$CODESIGN_IDENTITY_HASH" \
281+ --keychain "$KEYCHAIN_PATH" \
282+ "$GHOSTTY_VT"
283+
284+ codesign -vvv "$GHOSTTY_VT"
285+
188286 - name : Build and archive
189287 working-directory : ${{ env.PROJECT_PATH }}
190288 env :
0 commit comments