Shared build-script helpers for the codewhale-cli, codewhale-tui, and
codewhale-telemetry build scripts: rerun-condition declarations, the
embedded DEEPSEEK_BUILD_VERSION metadata, and the release-only build sha.
Only call these functions from a build script — they emit cargo:
directives on stdout.
Two different shas live here and they are not interchangeable.
DEEPSEEK_BUILD_VERSION/CODEWHALE_BUILD_COMMIT describe the build the
environment asked for (DEEPSEEK_BUILD_SHA/GITHUB_SHA); an unstamped
local build renders a (dev) marker instead.
CODEWHALE_RELEASE_BUILD_SHA describes a published binary and has no
fallback at all, because it leaves the machine.
Why the stamp never reads the local checkout (#5245)
These helpers used to watch .git/HEAD/refs and fall back to
git rev-parse HEAD, so every local commit invalidated the two largest
compile units in the workspace (a ~14-minute release rebuild with zero
code changes). And the alternative — resolving the sha at runtime —
would lie: the binary runs inside users' repositories, and a stale binary
would report whatever the checkout's HEAD is now, which breaks the
dogfood-receipt identity scripts/release/install-dogfood.sh verifies.
So the contract is: a sha appears in the version string only when the
build environment supplied one (DEEPSEEK_BUILD_SHA wins over
GITHUB_SHA), the build script reruns only when those variables change,
and a build nobody stamped says (dev). CI and release builds are
byte-identical to the old behavior; dogfood builds pass the sha
explicitly (the install script prints the exact command).