-
Notifications
You must be signed in to change notification settings - Fork 233
85 lines (80 loc) · 3.23 KB
/
build-platformio.yml
File metadata and controls
85 lines (80 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build Firmware
on:
release:
types: [published]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
env: [ESP32, ESP32-S3, ESP32-C3]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache pip
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v5
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio-${{ hashFiles('platformio.ini') }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio esptool
- name: Run PlatformIO
run: pio run -e ${{ matrix.env }}
- name: Determine tag
id: tag
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
TAG=$(git describe --tags --always)
echo "TAG=$TAG" >> $GITHUB_OUTPUT
fi
- name: Create merged binary
run: |
CHIP=esp32
BOOT_ADDR=0x1000
if [[ "${{ matrix.env }}" == *"S3"* ]]; then CHIP=esp32s3; BOOT_ADDR=0x0; fi
if [[ "${{ matrix.env }}" == *"C3"* ]]; then CHIP=esp32c3; BOOT_ADDR=0x0; fi
BOOT_APP0=$(find ~/.platformio/packages -name "boot_app0.bin" -path "*/partitions/*" | head -1)
python -m esptool --chip "$CHIP" merge_bin -o .pio/build/${{ matrix.env }}/firmware-full.bin \
--flash_mode dio --flash_freq 40m --flash_size 4MB \
"$BOOT_ADDR" .pio/build/${{ matrix.env }}/bootloader.bin \
0x8000 .pio/build/${{ matrix.env }}/partitions.bin \
0xe000 "$BOOT_APP0" \
0x10000 .pio/build/${{ matrix.env }}/firmware.bin
- name: Rename binaries
run: |
mv .pio/build/${{ matrix.env }}/firmware.bin .pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-ota.bin
mv .pio/build/${{ matrix.env }}/firmware-full.bin .pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-full.bin
- name: Archive build artifacts
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v7
with:
name: firmware-${{ matrix.env }}
path: |
.pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-ota.bin
.pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-full.bin
- name: Upload firmware to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: |
.pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-ota.bin
.pio/build/${{ matrix.env }}/tinygs-${{ matrix.env }}-${{ steps.tag.outputs.TAG }}-full.bin