build.sh: put the published build number in observer asset filenames

Stamp FIRMWARE_BUILD_NUMBER into FIRMWARE_VERSION_STRING (the output
filename), so production assets become <env>-v1.16.0.N-<hash>.bin and the
web flasher's Version dropdown (parsed from the asset name by the /releases
Worker) shows the true published build instead of the bare base version.

The build-number suffix is computed once, up front, and now feeds BOTH the
filename and the embedded -DFIRMWARE_VERSION (byte-for-byte unchanged, it
already carried .N). Local builds without the counter still produce
3-segment names, so OTA and every filename parser stay backward-compatible.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
agessamanandClaude Opus 4.8 committed 2026-07-22 11:29:54 -07:00
1 parent d14ec41301
commit 643a1ba41b
1 file changed
+23 -14
+23 -14
View File
@@ -133,9 +133,24 @@ build_firmware() {
exit 1
fi
# Observer build number: when CI provides FIRMWARE_BUILD_NUMBER (the per-base
# published-build counter), it becomes a 4th version component (e.g. .5 ->
# v1.16.0.5). Computed up front because it now feeds BOTH the filename and the
# embedded version. Local dev builds leave it unset → no 4th component.
BUILD_NUMBER_SUFFIX=""
if [ -n "$FIRMWARE_BUILD_NUMBER" ]; then
BUILD_NUMBER_SUFFIX=".${FIRMWARE_BUILD_NUMBER}"
fi
# set firmware version string (used for the output filename)
# e.g: v1.0.0-abcdef
FIRMWARE_VERSION_STRING="${FIRMWARE_VERSION}-${COMMIT_HASH}"
# e.g: v1.0.0-abcdef — or v1.16.0.5-abcdef with a build number. The build
# number is now IN the filename so the web flasher's Version dropdown (parsed
# from the asset name by the /releases Worker) shows the true published build,
# matching the embedded version that `ver` reports. Every filename parser
# (flasher gen-slim-manifests ASSET_RE, the /releases Worker VERSION_RE,
# flasher.js stale-URL recovery) accepts an optional 4th ".<n>" component
# between version and hash.
FIRMWARE_VERSION_STRING="${FIRMWARE_VERSION}${BUILD_NUMBER_SUFFIX}-${COMMIT_HASH}"
# craft filename
# e.g: RAK_4631_Repeater-v1.0.0-SHA
@@ -143,23 +158,17 @@ build_firmware() {
# Tag the *embedded* version for observer builds, e.g. v1.0.0-observer-abcdef,
# so `ver`, the MQTT firmware_version/client_version, and SNMP all identify the
# fork. The filename above is intentionally left untagged: the env name already
# contains "observer", and the web flasher keys off that existing pattern.
# fork. The filename above carries the same version + build number but no
# variant tag: the env name already contains "observer", and the web flasher
# keys off that existing pattern.
VARIANT_TAG=""
case "$1" in
*observer*) VARIANT_TAG="-observer" ;;
esac
# Observer build number: when CI provides FIRMWARE_BUILD_NUMBER (the per-base
# published-build counter), append it as a 4th version component so the node
# reports e.g. v1.16.0.5-observer-abcdef and `ota check` can show how many
# builds behind it is. Local dev builds leave it unset → no 4th component.
# The *filename* (FIRMWARE_VERSION_STRING above) is deliberately left without
# the build number so assets stay <env>-v<base>-<hash>.bin.
BUILD_NUMBER_SUFFIX=""
if [ -n "$FIRMWARE_BUILD_NUMBER" ]; then
BUILD_NUMBER_SUFFIX=".${FIRMWARE_BUILD_NUMBER}"
fi
# Embedded version: base + build number (4th component) + variant tag + hash,
# e.g. v1.16.0.5-observer-abcdef, so the node reports its build and `ota check`
# can show how many builds behind it is.
EMBEDDED_VERSION_STRING="${FIRMWARE_VERSION}${BUILD_NUMBER_SUFFIX}${VARIANT_TAG}-${COMMIT_HASH}"
# add firmware version info to end of existing platformio build flags in environment vars.