Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(ci): resolve Intel Mac binary architecture mismatch (#196)

Gabriel Stein0580e1e0b1cf
diff --git a/.github/workflows/build-and-notarize.yml b/.github/workflows/build-and-notarize.yml
index 48f103a02..45c910211 100644
--- a/.github/workflows/build-and-notarize.yml
+++ b/.github/workflows/build-and-notarize.yml
@@ -172,7 +172,7 @@ jobs:
uses: actions/cache@v4
with:
path: resources/bin
- key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift') }}
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift') }}
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 14a872ed1..69232364d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -157,7 +157,7 @@ jobs:
uses: actions/cache@v4
with:
path: resources/bin
- key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift') }}
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js', 'scripts/build-globe-listener.js', 'resources/macos-globe-listener.swift', 'scripts/build-macos-fast-paste.js', 'resources/macos-fast-paste.swift') }}
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
diff --git a/.gitignore b/.gitignore
index 80e6d0cb3..0e3eb2931 100644
--- a/.gitignore
+++ b/.gitignore
@@ -310,4 +310,7 @@ skills/
ehthumbs.db
Thumbs.db
.macos-globe-listener.hash
+.macos-globe-listener.*.hash
+.macos-fast-paste.hash
+.macos-fast-paste.*.hash
.linux-fast-paste.hash
diff --git a/scripts/build-macos-fast-paste.js b/scripts/build-macos-fast-paste.js
index 9163e0426..72cb9af34 100644
--- a/scripts/build-macos-fast-paste.js
+++ b/scripts/build-macos-fast-paste.js
@@ -10,11 +10,26 @@ if (!isMac) {
process.exit(0);
}
+// Support cross-compilation via --arch flag or TARGET_ARCH env var
+const archIndex = process.argv.indexOf("--arch");
+const targetArch =
+ (archIndex !== -1 && process.argv[archIndex + 1]) || process.env.TARGET_ARCH || process.arch;
+
+const ARCH_TO_TARGET = {
+ arm64: "arm64-apple-macosx11.0",
+ x64: "x86_64-apple-macosx10.15",
+};
+const swiftTarget = ARCH_TO_TARGET[targetArch];
+if (!swiftTarget) {
+ console.error(`[fast-paste] Unsupported architecture: ${targetArch}`);
+ process.exit(1);
+}
+
const projectRoot = path.resolve(__dirname, "..");
const swiftSource = path.join(projectRoot, "resources", "macos-fast-paste.swift");
const outputDir = path.join(projectRoot, "resources", "bin");
const outputBinary = path.join(outputDir, "macos-fast-paste");
-const hashFile = path.join(outputDir, ".macos-fast-paste.hash");
+const hashFile = path.join(outputDir, `.macos-fast-paste.${targetArch}.hash`);
const moduleCacheDir = path.join(outputDir, ".swift-module-cache");
function log(message) {
@@ -86,6 +101,8 @@ function attemptCompile(command, args) {
const compileArgs = [
swiftSource,
"-O",
+ "-target",
+ swiftTarget,
"-module-cache-path",
moduleCacheDir,
"-o",
@@ -117,4 +134,4 @@ try {
log(`Warning: Could not save source hash: ${err.message}`);
}
-log("Successfully built macOS fast-paste binary.");
+log(`Successfully built macOS fast-paste binary (${targetArch}).`);
diff --git a/scripts/lib/download-utils.js b/scripts/lib/download-utils.js
index 9944c1648..c767f65e0 100644
--- a/scripts/lib/download-utils.js
+++ b/scripts/lib/download-utils.js
@@ -45,7 +45,9 @@ function fetchJson(url, redirectCount = 0) {
reject(new Error("Redirect without location header"));
return;
}
- fetchJson(redirectUrl, redirectCount + 1).then(resolve).catch(reject);
+ fetchJson(redirectUrl, redirectCount + 1)
+ .then(resolve)
+ .catch(reject);
return;
}
@@ -211,7 +213,8 @@ function downloadFile(url, dest, retryCount = 0) {
request(url);
}).catch(async (error) => {
- const isTransient = error.message.includes("timed out") ||
+ const isTransient =
+ error.message.includes("timed out") ||
error.code === "ECONNRESET" ||
error.code === "ETIMEDOUT";
@@ -293,7 +296,8 @@ function parseArgs() {
isCurrent: args.includes("--current"),
isAll: args.includes("--all"),
isForce: args.includes("--force"),
- shouldCleanup: args.includes("--clean") ||
+ shouldCleanup:
+ args.includes("--clean") ||
process.env.CI === "true" ||
process.env.GITHUB_ACTIONS === "true",
};