# Release Scripts Design

## Goal

Consistent, repeatable release builds for macOS (Intel + ARM) and Linux (x86_64 + ARM64). Artifacts are tarballs uploaded to Bitbucket Downloads.

## Targets

| Platform | Triple | Build Method |
|----------|--------|-------------|
| macOS Intel | `x86_64-apple-darwin` | Local `cargo build` |
| macOS ARM | `aarch64-apple-darwin` | Local `cargo build` |
| Linux x86_64 | `x86_64-unknown-linux-musl` | Pipeline: `cargo build`, Local: `cross` |
| Linux ARM64 | `aarch64-unknown-linux-musl` | Pipeline: `cargo build`, Local: `cross` |

musl targets produce fully static Linux binaries with no glibc dependency.

## Artifacts

**Naming:** `fafb-q-{version}-{target}.tar.gz`

- Tag builds: version = tag (e.g., `v0.2.0`)
- Manual/dev builds: version = `dev-{short-sha}`

**Tarball contents:**
```
fafb-q-{version}-{target}/
  fafb-q                  # binary
  config.example.toml     # example configuration
```

## Components

### 1. Cargo.toml changes

- Add `[[bin]] name = "fafb-q"` so the binary is always named `fafb-q`
- Add `[profile.release]` with `lto = true`, `strip = true`, `codegen-units = 1`

### 2. scripts/release.sh

Single script that:
- Detects host OS (macOS vs Linux)
- Accepts `--target` for a single target or `--all` for all targets appropriate to the host
- On macOS: builds macOS targets natively, Linux targets via `cross`
- On Linux: builds Linux targets natively (used by pipeline)
- Packages each target into a tarball under `target/release-artifacts/`
- Version from `--version` flag, git tag, or `dev-{sha}` fallback

### 3. bitbucket-pipelines.yml

- **Tag trigger (`v*`):** builds both Linux musl targets, uploads to Bitbucket Downloads
- **Manual (custom) pipeline:** same build, for ad-hoc testing from any branch
- Uses `rustup` + native cargo (no `cross` needed — pipeline is already Linux)
- Installs musl toolchains via `apt` + `rustup target add`

### 4. docs/release-checklist.md

Step-by-step process covering the split local/CI workflow.

## Decisions

- **musl over glibc** — static binaries, no runtime dependency issues
- **`cross` only for local cross-compilation** — pipeline is already Linux, no Docker-in-Docker
- **Binary renamed in Cargo.toml** — not during packaging, so all builds produce `fafb-q`
- **macOS builds are local-only** — Bitbucket Pipelines has no macOS runners
