Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

ci: use system mac ffmpeg sidecars in release

Louis Beaumontb73cf7f930f6
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index adeb2eaea..0c20978df 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -547,6 +547,8 @@ jobs:
- name: Run pre_build.js
run: bun ./scripts/pre_build.js ${{ matrix.pre-build-args }}
working-directory: ${{ github.workspace }}/apps/screenpipe-app-tauri
+ env:
+ SCREENPIPE_RELEASE_TARGET: ${{ matrix.target }}
- name: Use production config for release
shell: bash
diff --git a/apps/screenpipe-app-tauri/scripts/pre_build.js b/apps/screenpipe-app-tauri/scripts/pre_build.js
index 567c11117..b1341c31c 100644
--- a/apps/screenpipe-app-tauri/scripts/pre_build.js
+++ b/apps/screenpipe-app-tauri/scripts/pre_build.js
@@ -284,6 +284,15 @@ async function linkSystemBinary(binaryName, destination) {
}
}
+async function copySystemBinary(binaryName, destination) {
+ const source = await findOnPath(binaryName);
+ if (!source) {
+ throw new Error(`CI expected ${binaryName} on PATH, but command lookup failed`);
+ }
+ await copyFile(source, destination);
+ console.log(`using system ${binaryName}: ${source} -> ${destination}`);
+}
+
async function findOnPath(binaryName) {
const pathValue = process.env.PATH || '';
for (const dir of pathValue.split(path.delimiter)) {
@@ -537,39 +546,51 @@ if (platform == 'windows') {
/* ########## macOS ########## */
if (platform == 'macos') {
- // Setup ffmpeg and ffprobe for both arm64 and x86_64
- // ref: https://github.com/nathanbabcock/ffmpeg-sidecar/blob/b0ab2e1233451f219e302bf78cbbb6a5a8e85aa4/src/download.rs#L31
- if (!(await fs.exists(`ffmpeg-aarch64-apple-darwin`))) {
- await $`wget --no-config ${config.macos.ffmpegUrlArm} -O ffmpeg-aarch64.zip`;
- await $`unzip -o ffmpeg-aarch64.zip -d ffmpeg-aarch64`;
- await $`cp ffmpeg-aarch64/ffmpeg ffmpeg-aarch64-apple-darwin`;
- await $`rm ffmpeg-aarch64.zip`;
- await $`rm -rf ffmpeg-aarch64`;
- }
-
- if (!(await fs.exists(`ffprobe-aarch64-apple-darwin`))) {
- await $`wget --no-config ${config.macos.ffprobeUrlArm} -O ffprobe-aarch64.zip`;
- await $`unzip -o ffprobe-aarch64.zip -d ffprobe-aarch64`;
- await $`cp ffprobe-aarch64/ffprobe ffprobe-aarch64-apple-darwin`;
- await $`rm ffprobe-aarch64.zip`;
- await $`rm -rf ffprobe-aarch64`;
- }
-
- if (!(await fs.exists(`ffmpeg-x86_64-apple-darwin`))) {
- await $`wget --no-config ${config.macos.ffmpegUrlx86_64} -O ffmpeg-x86_64.zip`;
- await $`unzip -o ffmpeg-x86_64.zip -d ffmpeg-x86_64`;
- await $`cp ffmpeg-x86_64/ffmpeg ffmpeg-x86_64-apple-darwin`;
- await $`rm ffmpeg-x86_64.zip`;
- await $`rm -rf ffmpeg-x86_64`;
- }
-
- if (!(await fs.exists(`ffprobe-x86_64-apple-darwin`))) {
- await $`wget --no-config ${config.macos.ffprobeUrlx86_64} -O ffprobe-x86_64.zip`;
- await $`unzip -o ffprobe-x86_64.zip -d ffprobe-x86_64`;
- await $`cp ffprobe-x86_64/ffprobe ffprobe-x86_64-apple-darwin`;
- await $`rm ffprobe-x86_64.zip`;
- await $`rm -rf ffprobe-x86_64`;
- }
+ const inCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
+ const releaseTarget = process.env.SCREENPIPE_RELEASE_TARGET;
+
+ if (inCI && releaseTarget) {
+ if (!(await fs.exists(`ffmpeg-${releaseTarget}`))) {
+ await copySystemBinary('ffmpeg', `ffmpeg-${releaseTarget}`);
+ }
+ if (!(await fs.exists(`ffprobe-${releaseTarget}`))) {
+ await copySystemBinary('ffprobe', `ffprobe-${releaseTarget}`);
+ }
+ } else {
+ // Setup ffmpeg and ffprobe for both arm64 and x86_64
+ // ref: https://github.com/nathanbabcock/ffmpeg-sidecar/blob/b0ab2e1233451f219e302bf78cbbb6a5a8e85aa4/src/download.rs#L31
+ if (!(await fs.exists(`ffmpeg-aarch64-apple-darwin`))) {
+ await $`wget --no-config ${config.macos.ffmpegUrlArm} -O ffmpeg-aarch64.zip`;
+ await $`unzip -o ffmpeg-aarch64.zip -d ffmpeg-aarch64`;
+ await $`cp ffmpeg-aarch64/ffmpeg ffmpeg-aarch64-apple-darwin`;
+ await $`rm ffmpeg-aarch64.zip`;
+ await $`rm -rf ffmpeg-aarch64`;
+ }
+
+ if (!(await fs.exists(`ffprobe-aarch64-apple-darwin`))) {
+ await $`wget --no-config ${config.macos.ffprobeUrlArm} -O ffprobe-aarch64.zip`;
+ await $`unzip -o ffprobe-aarch64.zip -d ffprobe-aarch64`;
+ await $`cp ffprobe-aarch64/ffprobe ffprobe-aarch64-apple-darwin`;
+ await $`rm ffprobe-aarch64.zip`;
+ await $`rm -rf ffprobe-aarch64`;
+ }
+
+ if (!(await fs.exists(`ffmpeg-x86_64-apple-darwin`))) {
+ await $`wget --no-config ${config.macos.ffmpegUrlx86_64} -O ffmpeg-x86_64.zip`;
+ await $`unzip -o ffmpeg-x86_64.zip -d ffmpeg-x86_64`;
+ await $`cp ffmpeg-x86_64/ffmpeg ffmpeg-x86_64-apple-darwin`;
+ await $`rm ffmpeg-x86_64.zip`;
+ await $`rm -rf ffmpeg-x86_64`;
+ }
+
+ if (!(await fs.exists(`ffprobe-x86_64-apple-darwin`))) {
+ await $`wget --no-config ${config.macos.ffprobeUrlx86_64} -O ffprobe-x86_64.zip`;
+ await $`unzip -o ffprobe-x86_64.zip -d ffprobe-x86_64`;
+ await $`cp ffprobe-x86_64/ffprobe ffprobe-x86_64-apple-darwin`;
+ await $`rm ffprobe-x86_64.zip`;
+ await $`rm -rf ffprobe-x86_64`;
+ }
+ }
console.log('FFMPEG and FFPROBE checks completed');
console.log('Moved and renamed ffmpeg binary for externalBin');