diff --git a/.github/workflows/build-observer-firmwares.yml b/.github/workflows/build-observer-firmwares.yml new file mode 100644 index 000000000..fb05ee7a5 --- /dev/null +++ b/.github/workflows/build-observer-firmwares.yml @@ -0,0 +1,133 @@ +name: Build MQTT Observer Firmwares + +permissions: + contents: write + +on: + workflow_dispatch: + push: + branches: + - mqtt-bridge-implementation-flex + +env: + # Version embedded in firmware filenames; must match the version key in the + # flasher's config.json. Bump here when the observer version changes. + FIRMWARE_VERSION: v1.16.0 + # Rolling release tag that hosts the latest observer binaries. + RELEASE_TAG: observer-mqtt-latest + +jobs: + + # Discover the *_observer_mqtt envs and split them into SHARDS groups so the + # build fans out across runners (pio builds envs sequentially within a job). + enumerate: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.split.outputs.matrix }} + steps: + - name: Clone Repo + uses: actions/checkout@v4 + + - name: Split observer envs into shards + id: split + shell: bash + run: | + SHARDS=4 + ENVS=$(grep -rhoE '^\[env:[^]]*observer_mqtt\]' platformio.ini variants/*/platformio.ini \ + | sed -E 's/^\[env:(.*)\]$/\1/' | sort -u) + echo "Discovered envs:"; echo "$ENVS" + MATRIX=$(echo "$ENVS" | awk -v n="$SHARDS" ' + { shard[NR % n] = shard[NR % n] " " $0 } + END { for (i = 0; i < n; i++) { sub(/^ /, "", shard[i]); + printf "{\"idx\":%d,\"envs\":\"%s\"}\n", i, shard[i] } }' \ + | jq -cs .) + echo "matrix=$MATRIX" >> "$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: + needs: enumerate + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + shard: ${{ fromJSON(needs.enumerate.outputs.matrix) }} + steps: + - name: Clone Repo + uses: actions/checkout@v4 + + - name: Setup Build Environment + uses: ./.github/actions/setup-build-environment + + - name: Build Shard ${{ matrix.shard.idx }} + run: /usr/bin/env bash build.sh build-firmware ${{ matrix.shard.envs }} + + - name: Upload Shard Artifact + uses: actions/upload-artifact@v4 + with: + name: fw-${{ matrix.shard.idx }} + path: out + if-no-files-found: error + + # 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 + runs-on: ubuntu-latest + steps: + - name: Clone Repo + uses: actions/checkout@v4 + + - name: Download All Shard Artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Flatten into out/ + run: | + mkdir -p out + find artifacts -type f -name '*.bin' -exec cp -f {} out/ \; + echo "Collected binaries:"; ls -1 out + + - name: Compute Short SHA + id: sha + run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + + - name: Recreate Rolling Release + env: + GH_TOKEN: ${{ github.token }} + run: gh release delete "$RELEASE_TAG" --yes --cleanup-tag || true + + - name: Publish Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.RELEASE_TAG }} + name: MQTT Observer Firmwares (${{ steps.sha.outputs.short }}) + body: "Rolling build of all *_observer_mqtt firmwares at ${{ steps.sha.outputs.short }}." + prerelease: true + files: out/* + + - name: Checkout Flasher Repo + uses: actions/checkout@v4 + with: + repository: agessaman/flasher.meshcore.io + token: ${{ secrets.FLASHER_DISPATCH_TOKEN }} + path: flasher + + - name: Update Flasher Config + run: | + python3 flasher/scripts/update-firmware.py \ + "${{ steps.sha.outputs.short }}" \ + "$GITHUB_WORKSPACE/firmware-notes.html" + + - name: Commit & Push Flasher Config + working-directory: flasher + run: | + if git diff --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 push diff --git a/firmware-notes.html b/firmware-notes.html new file mode 100644 index 000000000..e5b2a8fd5 --- /dev/null +++ b/firmware-notes.html @@ -0,0 +1 @@ +MQTT Observer v1.16.0 (experimental)

See setup guide for configuration instructions.