Added macos build script

This commit is contained in:
patben8 committed 2026-11-02 22:31:57 +01:00
1 parent f5e7202f3f
commit 2fcf6e7070
2 files changed
+88 -1

No files matched your search

+6 -1
View File
@@ -1483,6 +1483,10 @@ Two independent apps that talk over HTTP:
```bash ```bash
./dev.sh # start both servers (see README for one-time setup) ./dev.sh # start both servers (see README for one-time setup)
.\dev.ps1 # the same on Windows (BUILDING-WINDOWS.md) .\dev.ps1 # the same on Windows (BUILDING-WINDOWS.md)
./build.sh # desktop app on macOS: sidecar + .app/.dmg
# (--skip-sidecar reuses the staged one; other
# args go to `tauri build`)
.\build.ps1 # the same on Windows
# Backend # Backend
cd backend && source .venv/bin/activate cd backend && source .venv/bin/activate
@@ -2241,7 +2245,8 @@ that number and nothing else — everything derives from it:
`tauri.conf.json` `plugins.updater.pubkey`. **Losing the private key means `tauri.conf.json` `plugins.updater.pubkey`. **Losing the private key means
installed copies can never update themselves again** — it is backed up installed copies can never update themselves again** — it is backed up
outside the repo. A local build without it passes outside the repo. A local build without it passes
`--config src-tauri/tauri.unsigned.conf.json` (`build.ps1` does so itself). `--config src-tauri/tauri.unsigned.conf.json` (`build.sh` / `build.ps1` do
so themselves).
- **NOT a source**: `src-tauri/Cargo.toml` `version` is inert Rust crate metadata - **NOT a source**: `src-tauri/Cargo.toml` `version` is inert Rust crate metadata
(Tauri uses the config's `../package.json`); don't treat it as the app version. (Tauri uses the config's `../package.json`); don't treat it as the app version.
Executable
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Build the Konduktor desktop app on macOS: freeze + stage the backend sidecar,
# then build the Tauri app (.app + .dmg). The macOS twin of build.ps1.
# One-time setup:
# python3 -m venv backend/.venv
# backend/.venv/bin/pip install -r backend/requirements.txt -r backend/requirements-build.txt
# (cd frontend && npm install)
# a Rust toolchain from https://rustup.rs
#
# ./build.sh # sidecar + app (release bundles)
# ./build.sh --skip-sidecar # frontend-only change: reuse the staged sidecar
# ./build.sh --debug # anything else is passed on to `tauri build`
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKIP_SIDECAR=0
TAURI_ARGS=()
for arg in "$@"; do
case "$arg" in
--skip-sidecar) SKIP_SIDECAR=1 ;;
*) TAURI_ARGS+=("$arg") ;;
esac
done
die() { echo "error: $*" >&2; exit 1; }
[ -x "$ROOT/backend/.venv/bin/python" ] || die "No backend venv at backend/.venv - see the one-time setup at the top of build.sh."
[ -d "$ROOT/frontend/node_modules" ] || die "No frontend/node_modules - run \`npm install\` in frontend first."
STAGED="$ROOT/frontend/src-tauri/binaries/konduktor-sidecar/konduktor-sidecar"
# rustup adds ~/.cargo/bin to PATH only in shells started AFTER the install -
# look there before giving up, rather than failing after the sidecar build.
if ! command -v cargo >/dev/null 2>&1; then
[ -x "$HOME/.cargo/bin/cargo" ] || die "No Rust toolchain (cargo) - install it from https://rustup.rs."
export PATH="$HOME/.cargo/bin:$PATH"
fi
# Bundles newer than this marker are this run's (release or --debug profile).
MARKER="$(mktemp)"
trap 'rm -f "$MARKER"' EXIT
if [ "$SKIP_SIDECAR" = 1 ]; then
[ -x "$STAGED" ] || die "No staged sidecar to reuse - run without --skip-sidecar first."
echo "==> Reusing the staged sidecar (--skip-sidecar)"
else
echo "==> 1/2 Freezing the backend sidecar"
PY="$ROOT/backend/.venv/bin/python" "$ROOT/backend/build_sidecar.sh"
fi
# Updater packages are signed with the release key (CI's secret). Without it,
# build the app and .dmg alone rather than fail at the signing step.
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
TAURI_ARGS=(--config src-tauri/tauri.unsigned.conf.json ${TAURI_ARGS[@]+"${TAURI_ARGS[@]}"})
fi
# A failed .dmg step leaves its read-write image behind (`rw.<pid>.*.dmg`,
# hundreds of MB each); clear old ones.
find "$ROOT/frontend/src-tauri/target" -path '*/bundle/macos/rw.*.dmg' -delete 2>/dev/null || true
echo ""
echo "==> 2/2 Building the app (tauri build ${TAURI_ARGS[*]+${TAURI_ARGS[*]}})"
LOG="$(mktemp)"
trap 'rm -f "$MARKER" "$LOG"' EXIT
if ! (cd "$ROOT/frontend" && npx tauri build ${TAURI_ARGS[@]+"${TAURI_ARGS[@]}"}) 2>&1 | tee "$LOG"; then
# The .dmg step mounts a fresh image and has Finder lay it out, which fails
# now and then (measured: the same build passed on a rerun). The .app is
# already built by then, so retry just the .dmg once before giving up.
grep -q 'bundle_dmg.sh' "$LOG" || exit 1
echo ""
echo "==> The .dmg step failed; retrying it once"
(cd "$ROOT/frontend" && npx tauri build ${TAURI_ARGS[@]+"${TAURI_ARGS[@]}"} --bundles dmg)
fi
echo ""
BUILT="$(find "$ROOT/frontend/src-tauri/target" -path '*/bundle/*' \( -name '*.dmg' -o -name '*.app' \) \
-newer "$MARKER" -prune 2>/dev/null || true)"
if [ -n "$BUILT" ]; then
echo "Built:"
echo "$BUILT" | sed 's/^/ /'
else
echo "Done (nothing bundled - see frontend/src-tauri/target/)."
fi