feat(ota): implement build number suffix for firmware versioning

Enhanced the firmware versioning system by appending a build number
suffix when available, allowing for better tracking of published builds.
This change improves the OTA update process by providing clearer
versioning information in the embedded firmware string.
This commit is contained in:
agessaman
2026-06-23 12:55:07 -07:00
parent addb637b63
commit 730eb37dbd
19 changed files with 203 additions and 123 deletions
+49 -3
View File
@@ -47,6 +47,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.split.outputs.matrix }}
build_number: ${{ steps.buildnum.outputs.n }}
steps:
- name: Clone Repo
uses: actions/checkout@v4
@@ -66,6 +67,27 @@ jobs:
| jq -cs .)
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
- name: Compute observer build number
id: buildnum
shell: bash
run: |
# Per-base published-build counter. N increments once per release and
# resets to 1 when FIRMWARE_VERSION (the MeshCore base version) changes.
# Read-only here (off the published counter); the release job is the sole
# writer and only writes on a successful build, so a failed build doesn't
# burn a number. First run / 404 -> empty -> N=1.
COUNTER_URL="https://observer.gessaman.com/observer-build-counter.json"
CUR=$(curl -fsSL "$COUNTER_URL" 2>/dev/null || echo '{}')
PREV_BASE=$(echo "$CUR" | jq -r '.baseVersion // ""')
PREV_BUILD=$(echo "$CUR" | jq -r '.build // 0')
if [ "$PREV_BASE" = "$FIRMWARE_VERSION" ]; then
N=$((PREV_BUILD + 1))
else
N=1
fi
echo "Base $FIRMWARE_VERSION; previous build $PREV_BUILD (base $PREV_BASE) -> N=$N"
echo "n=$N" >> "$GITHUB_OUTPUT"
# Build one shard (several envs) per runner. build.sh emits both the app
# .bin and the ESP32 -merged.bin into out/ for each env.
build:
@@ -100,6 +122,9 @@ jobs:
uses: ./.github/actions/setup-build-environment
- name: Build Shard ${{ matrix.shard.idx }}
env:
# Stamp the per-base build number into the embedded version (v1.16.0.N).
FIRMWARE_BUILD_NUMBER: ${{ needs.enumerate.outputs.build_number }}
run: /usr/bin/env bash build.sh build-firmware ${{ matrix.shard.envs }}
- name: Upload Shard Artifact
@@ -112,7 +137,7 @@ jobs:
# Collect all shard outputs, publish the rolling release, then point the
# flasher at the new build by bumping the hash + notes in its config.json.
release:
needs: build
needs: [enumerate, build]
runs-on: ubuntu-latest
steps:
- name: Clone Repo
@@ -196,6 +221,23 @@ jobs:
"${{ steps.sha.outputs.short }}" \
"$GITHUB_WORKSPACE/firmware-notes.html"
- name: Generate Slim Per-Variant Manifests + Persist Build Counter
env:
BUILD_NUMBER: ${{ needs.enumerate.outputs.build_number }}
run: |
# Derive the slim per-variant manifests (flasher/v/<env>.json) that the
# firmware fetches for `ota check`/`ota update`, from the just-updated
# config.json (single source of truth), stamping this build's number.
# Then persist the counter so the next run increments from here.
python3 flasher/scripts/gen-slim-manifests.py \
--config flasher/config.json \
--out-dir flasher/v \
--base-version "$FIRMWARE_VERSION" \
--build "$BUILD_NUMBER"
printf '{\n "baseVersion": "%s",\n "build": %s\n}\n' \
"$FIRMWARE_VERSION" "$BUILD_NUMBER" > flasher/observer-build-counter.json
echo "Build $FIRMWARE_VERSION.$BUILD_NUMBER"
- name: Unshallow for Changelog
run: |
# gen_changelog.py needs the full branch history; deepen only now, AFTER
@@ -233,11 +275,15 @@ jobs:
- name: Commit & Push Flasher Config
working-directory: flasher
run: |
if git diff --quiet; then
# Stage everything: update-firmware.py edits config.json in place, but the
# slim manifests (v/*.json) and the build counter can be NEW files, which
# `commit -am` would miss — so add -A and check the staged diff.
git add -A
if git diff --cached --quiet; then
echo "No flasher changes to commit."
exit 0
fi
git config user.name "meshcore-bot"
git config user.email "noreply@gessaman.com"
git commit -am "Update observer firmware to ${{ steps.sha.outputs.short }}"
git commit -m "Update observer firmware to ${{ steps.sha.outputs.short }} (build ${FIRMWARE_VERSION}.${{ needs.enumerate.outputs.build_number }})"
git push