Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

build: bundle cap-muxer sidecar with desktop app and CI

Richie McIlroydf3e1e7fdaa1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 006c4ee79..ecbd21562 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -207,6 +207,10 @@ jobs:
- name: Output .env file
run: cat apps/desktop/.env
+ - name: Build cap-muxer sidecar
+ shell: bash
+ run: ./scripts/build-cap-muxer.sh ${{ matrix.settings.target }}
+
- name: Build app
working-directory: apps/desktop
run: |
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 01c54ffd2..b784864f0 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -188,6 +188,10 @@ jobs:
echo 'VITE_SERVER_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .env
echo 'RUST_TARGET_TRIPLE=${{ matrix.settings.target }}' >> .env
+ - name: Build cap-muxer sidecar
+ shell: bash
+ run: ./scripts/build-cap-muxer.sh ${{ matrix.settings.target }}
+
- name: Build app
working-directory: apps/desktop
run: |
diff --git a/apps/desktop/src-tauri/binaries/.gitignore b/apps/desktop/src-tauri/binaries/.gitignore
new file mode 100644
index 000000000..588e9b1c8
--- /dev/null
+++ b/apps/desktop/src-tauri/binaries/.gitignore
@@ -0,0 +1,2 @@
+cap-muxer-*
+!.gitignore
diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json
index 691c2f099..29432db8f 100644
--- a/apps/desktop/src-tauri/tauri.conf.json
+++ b/apps/desktop/src-tauri/tauri.conf.json
@@ -38,6 +38,7 @@
"active": true,
"createUpdaterArtifacts": true,
"targets": "all",
+ "externalBin": ["binaries/cap-muxer"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
diff --git a/scripts/build-cap-muxer.sh b/scripts/build-cap-muxer.sh
new file mode 100755
index 000000000..69e9c2e4b
--- /dev/null
+++ b/scripts/build-cap-muxer.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Build the cap-muxer sidecar binary with the target-triple suffix Tauri's
+# externalBin expects, and copy it into apps/desktop/src-tauri/binaries.
+#
+# Usage:
+# scripts/build-cap-muxer.sh # uses host triple
+# scripts/build-cap-muxer.sh <target-triple> # uses given triple
+#
+# Example target triples:
+# aarch64-apple-darwin
+# x86_64-apple-darwin
+# x86_64-pc-windows-msvc
+
+TARGET="${1:-}"
+if [[ -z "$TARGET" ]]; then
+ TARGET="$(rustc -vV | sed -n 's|host: ||p')"
+fi
+
+REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+BINARIES_DIR="$REPO_ROOT/apps/desktop/src-tauri/binaries"
+
+EXT=""
+case "$TARGET" in
+ *windows*) EXT=".exe" ;;
+esac
+
+echo "Building cap-muxer for $TARGET..."
+cargo build --release -p cap-muxer --target "$TARGET"
+
+mkdir -p "$BINARIES_DIR"
+
+SRC="$REPO_ROOT/target/$TARGET/release/cap-muxer$EXT"
+DEST="$BINARIES_DIR/cap-muxer-$TARGET$EXT"
+
+if [[ ! -f "$SRC" ]]; then
+ echo "error: built binary not found at $SRC" >&2
+ exit 1
+fi
+
+cp "$SRC" "$DEST"
+echo "Copied $(realpath "$SRC" 2>/dev/null || echo "$SRC") -> $DEST"