Skip to content

Build Scripts

The scripts/build/ directory contains all build pipelines and supporting code generators.

Overview

build/
├── all.sh              Full build (server + mobile)
├── server.sh           Server build pipeline
├── mobile.sh           Mobile build pipeline
├── generators/
│   ├── embeds.ts       Static file and migration embed generator
│   └── installer.ts    CLI bundler and installer generator
└── templates/
    └── installer.sh    Installer shell script template

Full Build (all.sh)

Runs the complete build pipeline for both server and mobile:

bash
bun build
# or directly: bash scripts/build/all.sh

Steps:

  1. Run server tests (bun test in server/)
  2. Run contract tests (bun scripts/test/contracts.ts)
  3. Build server binaries via server.sh --server-only
  4. Build mobile apps via mobile.sh

Server Build (server.sh)

Builds the web frontend, generates embeds, compiles Linux binaries, runs smoke tests, and optionally uploads.

bash
bun build:server
# or directly: bash scripts/build/server.sh

Flags:

  • --server-only — skip the upload step (used by all.sh)
  • --skip-upload — skip the upload step

Steps:

  1. Build web frontend (bun build.ts --release in web/)
  2. Generate static embeds (generators/embeds.ts)
  3. Generate installer script (generators/installer.ts)
  4. Compile Linux binaries (arm64 + x64) with bun build --compile
  5. Run binary smoke tests (scripts/test/binary.sh)
  6. Upload binaries and installer to deploy server (unless skipped)

Mobile Build (mobile.sh)

Builds the Flutter app for both platforms.

bash
bun build:mobile
# or directly: bash scripts/build/mobile.sh

Steps:

  1. Fetch Flutter dependencies
  2. Run Flutter analyze
  3. Build Android App Bundle (AAB)
  4. Build iOS IPA (macOS only, requires Xcode signing)
  5. Copy artifacts to releases/

Generators

generators/embeds.ts

Generates two files that embed assets into the compiled server binary:

  • server/src/static_embeds.ts — maps URL paths to web frontend files using import ... with { type: "file" }
  • server/src/migration_embeds.ts — bundles database migration code for runtime execution

This runs automatically as part of server.sh, but can also be run standalone:

bash
bun scripts/build/generators/embeds.ts

generators/installer.ts

Bundles the CLI TypeScript code (from scripts/cli/) into a single self-contained installer shell script:

  1. Uses Bun.build() to bundle cli/main.ts with all dependencies
  2. Reads the template from templates/installer.sh
  3. Replaces ###version###, ###util.sh###, and ###util.ts### placeholders
  4. Writes the final releases/installer.sh

Templates

templates/installer.sh

Shell script template with placeholder markers that generators/installer.ts fills in at build time. Contains the installer logic for downloading and setting up SafeCall on a production server.