Skip to content

Commit 8e23bd8

Browse files
author
Ravi Singh
committed
ci(release): recognize per-binary tag scheme (rx-v*, tx-v*, rxc3-v*)
The old workflow triggered on 'v*' only and referenced firmware/receiver/ + firmware/transmitter/ which don't exist on main. So no auto-release has worked since the firmware tree moved to capitalized board names. Updated: - Trigger on rx-v*, tx-v*, rxc3-v* (matches sync-to-public.yml in private) - Build ONE matching binary per tag based on prefix - Use actual paths: firmware/Receiver-ESP32-DevKit, Transmitter-IDF, Receiver-ESP32-C3 - Use the annotated tag body (written on private, mirrored by sync) as the GitHub Release body End-to-end flow: private: git tag -a rx-v2.8.5 -m "..." + git push origin rx-v2.8.5 → private sync-to-public.yml mirrors firmware/hardware/docs + pushes the tag to public → public build-firmware.yml (this) fires on the synced tag → builds the binary → publishes Release rx-v2.8.5 with the .bin + the tag-annotation body
1 parent 602d2e8 commit 8e23bd8

1 file changed

Lines changed: 78 additions & 61 deletions

File tree

Lines changed: 78 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,102 @@
11
name: Build & Release Firmware
22

3+
# Triggered when the sync workflow (in the private tanksync-cloud repo)
4+
# pushes a tag here. Per the per-binary tag scheme in RELEASES.md:
5+
#
6+
# rx-v* → builds firmware/Receiver-ESP32-DevKit/ for ESP32
7+
# tx-v* → builds firmware/Transmitter-IDF/ for ESP32-C3
8+
# rxc3-v* → builds firmware/Receiver-ESP32-C3/ for ESP32-C3
9+
#
10+
# Only ONE binary is built per tag (matches the tag prefix). The result is
11+
# attached to a GitHub Release on this public repo with notes generated
12+
# from the tag annotation that was written on private.
13+
314
on:
415
push:
516
tags:
6-
- 'v*'
17+
- 'rx-v*'
18+
- 'tx-v*'
19+
- 'rxc3-v*'
720

821
jobs:
922
build:
23+
name: Build firmware for ${{ github.ref_name }}
1024
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
include:
14-
- name: receiver
15-
path: firmware/receiver
16-
target: esp32
17-
binary: tanksync_receiver.bin
18-
- name: receiver-c3
19-
path: firmware/receiver-c3
20-
target: esp32c3
21-
binary: tanksync_receiver.bin
22-
- name: transmitter
23-
path: firmware/transmitter
24-
target: esp32c3
25-
binary: tanksync_transmitter.bin
25+
permissions:
26+
contents: write
2627

2728
steps:
2829
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0 # need full history so `git tag -l --format` reads annotation
32+
33+
- name: Identify target from tag
34+
id: meta
35+
run: |
36+
TAG="${GITHUB_REF_NAME}"
37+
case "${TAG}" in
38+
rx-v*)
39+
echo "kind=receiver" >> "$GITHUB_OUTPUT"
40+
echo "path=firmware/Receiver-ESP32-DevKit" >> "$GITHUB_OUTPUT"
41+
echo "target=esp32" >> "$GITHUB_OUTPUT"
42+
echo "binary=tanksync_receiver.bin" >> "$GITHUB_OUTPUT"
43+
echo "asset=tanksync-receiver-${TAG}.bin" >> "$GITHUB_OUTPUT"
44+
;;
45+
tx-v*)
46+
echo "kind=transmitter" >> "$GITHUB_OUTPUT"
47+
echo "path=firmware/Transmitter-IDF" >> "$GITHUB_OUTPUT"
48+
echo "target=esp32c3" >> "$GITHUB_OUTPUT"
49+
echo "binary=tanksync_transmitter.bin" >> "$GITHUB_OUTPUT"
50+
echo "asset=tanksync-transmitter-${TAG}.bin" >> "$GITHUB_OUTPUT"
51+
;;
52+
rxc3-v*)
53+
echo "kind=receiver-c3" >> "$GITHUB_OUTPUT"
54+
echo "path=firmware/Receiver-ESP32-C3" >> "$GITHUB_OUTPUT"
55+
echo "target=esp32c3" >> "$GITHUB_OUTPUT"
56+
echo "binary=tanksync_receiver.bin" >> "$GITHUB_OUTPUT"
57+
echo "asset=tanksync-receiver-c3-${TAG}.bin" >> "$GITHUB_OUTPUT"
58+
;;
59+
esac
2960
3061
- name: Build with ESP-IDF
3162
uses: espressif/esp-idf-ci-action@v1
3263
with:
3364
esp_idf_version: v5.4
34-
target: ${{ matrix.target }}
35-
path: ${{ matrix.path }}
65+
target: ${{ steps.meta.outputs.target }}
66+
path: ${{ steps.meta.outputs.path }}
3667

37-
- name: Rename binary
68+
- name: Rename binary for release
3869
run: |
39-
cp ${{ matrix.path }}/build/${{ matrix.binary }} \
40-
tanksync-${{ matrix.name }}-${{ github.ref_name }}.bin
41-
42-
- name: Upload artifact
43-
uses: actions/upload-artifact@v4
44-
with:
45-
name: ${{ matrix.name }}
46-
path: tanksync-${{ matrix.name }}-${{ github.ref_name }}.bin
70+
cp "${{ steps.meta.outputs.path }}/build/${{ steps.meta.outputs.binary }}" \
71+
"${{ steps.meta.outputs.asset }}"
72+
ls -la "${{ steps.meta.outputs.asset }}"
4773
48-
release:
49-
needs: build
50-
runs-on: ubuntu-latest
51-
permissions:
52-
contents: write
53-
steps:
54-
- uses: actions/download-artifact@v4
74+
- name: Read tag annotation as release body
75+
id: notes
76+
run: |
77+
BODY=$(git tag -l --format='%(contents)' "${GITHUB_REF_NAME}")
78+
{
79+
echo "body<<__END_OF_BODY__"
80+
echo "$BODY"
81+
echo ""
82+
echo "---"
83+
echo ""
84+
echo "### Flashing"
85+
echo ''
86+
echo '```bash'
87+
echo "esptool.py --chip ${{ steps.meta.outputs.target }} -b 460800 \\"
88+
echo " write_flash 0x10000 ${{ steps.meta.outputs.asset }}"
89+
echo '```'
90+
echo ""
91+
echo "Or use the [browser flasher](https://tanksync.smartghar.org/firmware) for a one-click install."
92+
echo "__END_OF_BODY__"
93+
} >> "$GITHUB_OUTPUT"
5594
5695
- name: Create GitHub Release
5796
uses: softprops/action-gh-release@v2
5897
with:
59-
files: |
60-
receiver/tanksync-receiver-${{ github.ref_name }}.bin
61-
receiver-c3/tanksync-receiver-c3-${{ github.ref_name }}.bin
62-
transmitter/tanksync-transmitter-${{ github.ref_name }}.bin
63-
generate_release_notes: true
64-
body: |
65-
## Firmware Binaries
66-
67-
| Binary | Board | Description |
68-
|--------|-------|-------------|
69-
| `tanksync-receiver-${{ github.ref_name }}.bin` | ESP32 DevKit | Receiver firmware |
70-
| `tanksync-receiver-c3-${{ github.ref_name }}.bin` | ESP32-C3 | Receiver firmware (C3 variant) |
71-
| `tanksync-transmitter-${{ github.ref_name }}.bin` | ESP32-C3 | Transmitter firmware |
72-
73-
### Flashing
74-
```bash
75-
# Receiver (ESP32 DevKit)
76-
esptool.py --chip esp32 -b 460800 write_flash 0x10000 tanksync-receiver-${{ github.ref_name }}.bin
77-
78-
# Receiver (ESP32-C3)
79-
esptool.py --chip esp32c3 -b 460800 write_flash 0x10000 tanksync-receiver-c3-${{ github.ref_name }}.bin
80-
81-
# Transmitter (ESP32-C3)
82-
esptool.py --chip esp32c3 -b 460800 write_flash 0x10000 tanksync-transmitter-${{ github.ref_name }}.bin
83-
```
84-
85-
Or use the **OTA update** via the receiver's web UI.
98+
files: ${{ steps.meta.outputs.asset }}
99+
body: ${{ steps.notes.outputs.body }}
100+
generate_release_notes: false
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)