A local-first private AI assistant for everyday use. Runs on-device models with encrypted P2P sync, and supports sharing chats publicly on ATProto.
1#!/usr/bin/env bash
2set -euo pipefail
3
4BINARY_NAME="tiles"
5# Folder where final tar.gz will be created
6DIST_DIR="dist"
7# Folder where we store the modelfiles, which will be copied to installer
8MODELFILE_DIR="modelfiles"
9# Py server folder, which will be copied to installer
10SERVER_DIR="server"
11# cargo build mode for production
12TARGET="release"
13
14# Fetching the tiles binary version from its cargo.toml version
15VERSION=$(grep '^version' tiles/Cargo.toml | head -1 | awk -F'"' '{print $2}')
16OS=$(uname -s | tr '[:upper:]' '[:lower:]')
17ARCH=$(uname -m)
18
19# Name for final tar.gz
20
21OUT_NAME="${BINARY_NAME}-v${VERSION}-${ARCH}-${OS}"
22
23echo "🚀 Building ${BINARY_NAME} (${TARGET} mode)..."
24
25cargo build -p tiles --${TARGET}
26
27
28# Destination where the release binary is generated
29CLI_BIN_PATH="target/${TARGET}/${BINARY_NAME}"
30
31chmod +x "${CLI_BIN_PATH}"
32
33echo "Signing the Tiles binary..."
34
35# Signing the tiles binary
36codesign --force \
37 --sign "$DEVELOPER_ID_APPLICATION"\
38 --options runtime \
39 --timestamp \
40 --strict \
41 "${CLI_BIN_PATH}"
42
43
44mkdir -p "${DIST_DIR}/tmp"
45
46cp "${CLI_BIN_PATH}" "${DIST_DIR}/tmp/"
47
48echo "Embedding Pi"
49# Copying pi artifacts into extracted pi folder
50cp pi-darwin-arm64.tar.gz "${DIST_DIR}/tmp/"
51
52tar -xvf "${DIST_DIR}/tmp/pi-darwin-arm64.tar.gz" -C "${DIST_DIR}/tmp"
53
54rm "${DIST_DIR}/tmp/pi-darwin-arm64.tar.gz"
55
56# removing unnecessary files
57# rm -rf "${DIST_DIR}/tmp/pi/examples"
58
59# Signing the pi binary
60
61echo "Signing Pi binary..."
62
63codesign --force \
64 --sign "$DEVELOPER_ID_APPLICATION" \
65 --options runtime \
66 --timestamp \
67 --entitlements entitleme.plist \
68 --strict \
69 "${DIST_DIR}/tmp/pi/pi"
70
71
72# flushing this folder, else the final zip will have previous app-server zips too (#84)
73rm -rf "${SERVER_DIR}/stack_export_prod"
74
75echo "🔒 Locking the venvstack...."
76
77venvstacks lock server/stack/venvstacks.toml
78
79echo "🛠️ Building the venvstack...."
80
81venvstacks build server/stack/venvstacks.toml
82
83echo "📦 Publishing the venvstack...."
84
85venvstacks publish --tag-outputs --output-dir ../stack_export_prod server/stack/venvstacks.toml
86
87cp -r "${SERVER_DIR}" "${DIST_DIR}/tmp/"
88
89rm -rf "${DIST_DIR}/tmp/server/__pycache__"
90# rm -rf "${DIST_DIR}/tmp/server/mem_agent/__pycache__"
91# rm -rf "${DIST_DIR}/tmp/server/backend/__pycache__"
92rm -rf "${DIST_DIR}/tmp/server/.venv"
93rm -rf "${DIST_DIR}/tmp/server/stack"
94
95cp -r "${MODELFILE_DIR}" "${DIST_DIR}/tmp/"
96
97echo "📦 Creating ${OUT_NAME}.tar.gz..."
98tar --exclude-from=scripts/tar.exclude -czf "${DIST_DIR}/${OUT_NAME}.tar.gz" -C "${DIST_DIR}/tmp" .
99
100rm -rf "${DIST_DIR}/tmp"
101
102echo "✅ Bundle created: ${DIST_DIR}/${OUT_NAME}.tar.gz"