|
1 | 1 | name: Build & Release Firmware |
2 | 2 |
|
| 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 | + |
3 | 14 | on: |
4 | 15 | push: |
5 | 16 | tags: |
6 | | - - 'v*' |
| 17 | + - 'rx-v*' |
| 18 | + - 'tx-v*' |
| 19 | + - 'rxc3-v*' |
7 | 20 |
|
8 | 21 | jobs: |
9 | 22 | build: |
| 23 | + name: Build firmware for ${{ github.ref_name }} |
10 | 24 | 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 |
26 | 27 |
|
27 | 28 | steps: |
28 | 29 | - 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 |
29 | 60 |
|
30 | 61 | - name: Build with ESP-IDF |
31 | 62 | uses: espressif/esp-idf-ci-action@v1 |
32 | 63 | with: |
33 | 64 | 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 }} |
36 | 67 |
|
37 | | - - name: Rename binary |
| 68 | + - name: Rename binary for release |
38 | 69 | 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 }}" |
47 | 73 |
|
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" |
55 | 94 |
|
56 | 95 | - name: Create GitHub Release |
57 | 96 | uses: softprops/action-gh-release@v2 |
58 | 97 | 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