From 2c129204195e23341030d6f4dad76bef0183185a Mon Sep 17 00:00:00 2001 From: Sagar Trivedi Date: Tue, 17 Mar 2026 12:01:29 +0700 Subject: [PATCH] fix: add x86_64 CI verification and fix YAML syntax error - Add x86_64 build step that compiles CodexBar, CodexBarCLI, and CodexBarClaudeWatchdog - Patch Recorder.swift to strip #Preview blocks (PreviewsMacros unavailable in CLI builds) - Use perl one-liner instead of Python heredoc to avoid YAML indentation parse error --- .github/workflows/ci.yml | 21 ++++++++++++++++++ Scripts/package_app.sh | 26 +++++++++++++++++++++++ Sources/CodexBar/MenuHighlightStyle.swift | 9 +++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de2359aca..7d8ac5fbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,27 @@ jobs: - name: Swift Test run: swift test --no-parallel + - name: Compile for x86_64 + run: | + set -euo pipefail + # KeyboardShortcuts 2.x added #Preview blocks in Recorder.swift that use + # PreviewsMacros — a plugin unavailable in command-line swift build. + # Strip them before building (same patch applied in package_app.sh). + recorder=".build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Recorder.swift" + if [[ -f "$recorder" ]] && grep -q '#Preview' "$recorder"; then + chmod +w "$recorder" + perl -0777 -i -pe 's/\n#Preview \{[^}]*\}//g' "$recorder" + fi + swift build -c release --arch x86_64 --product CodexBar + swift build -c release --arch x86_64 --product CodexBarCLI + swift build -c release --arch x86_64 --product CodexBarClaudeWatchdog + + - name: Build + package universal binary (ad-hoc signed) + run: | + set -euo pipefail + ARCHES="arm64 x86_64" CODEXBAR_SIGNING=adhoc ./Scripts/package_app.sh release + lipo -archs CodexBar.app/Contents/MacOS/CodexBar + build-linux-cli: strategy: fail-fast: false diff --git a/Scripts/package_app.sh b/Scripts/package_app.sh index 08ee481a0..63bd31bce 100755 --- a/Scripts/package_app.sh +++ b/Scripts/package_app.sh @@ -34,6 +34,31 @@ if [[ ${#ARCH_LIST[@]} -eq 0 ]]; then esac fi +patch_keyboard_shortcuts_recorder() { + local recorder_path="$ROOT/.build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Recorder.swift" + if [[ ! -f "$recorder_path" ]]; then + return 0 + fi + if ! grep -q '#Preview' "$recorder_path"; then + return 0 + fi + + chmod +w "$recorder_path" || true + python3 - "$recorder_path" <<'PY' +import sys, re +from pathlib import Path + +path = Path(sys.argv[1]) +text = path.read_text() + +# Remove #Preview { ... } blocks — they use PreviewsMacros which is unavailable +# when cross-compiling and are not needed for release builds. +patched = re.sub(r'\n#Preview \{[^}]*\}', '', text, flags=re.DOTALL) +if patched != text: + path.write_text(patched) +PY +} + patch_keyboard_shortcuts() { local util_path="$ROOT/.build/checkouts/KeyboardShortcuts/Sources/KeyboardShortcuts/Utilities.swift" if [[ ! -f "$util_path" ]]; then @@ -103,6 +128,7 @@ if [[ ! -f "$KEYBOARD_SHORTCUTS_UTIL" ]]; then swift build -c "$CONF" --arch "${ARCH_LIST[0]}" fi patch_keyboard_shortcuts +patch_keyboard_shortcuts_recorder for ARCH in "${ARCH_LIST[@]}"; do swift build -c "$CONF" --arch "$ARCH" diff --git a/Sources/CodexBar/MenuHighlightStyle.swift b/Sources/CodexBar/MenuHighlightStyle.swift index be76fe04a..d35b90270 100644 --- a/Sources/CodexBar/MenuHighlightStyle.swift +++ b/Sources/CodexBar/MenuHighlightStyle.swift @@ -1,7 +1,14 @@ import SwiftUI +private struct MenuItemHighlightedKey: EnvironmentKey { + static let defaultValue: Bool = false +} + extension EnvironmentValues { - @Entry var menuItemHighlighted: Bool = false + var menuItemHighlighted: Bool { + get { self[MenuItemHighlightedKey.self] } + set { self[MenuItemHighlightedKey.self] = newValue } + } } enum MenuHighlightStyle {