|
| 1 | +name: PlatformIO CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ["v*.*.*"] |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + - uses: actions/cache@v3 |
| 18 | + with: |
| 19 | + path: | |
| 20 | + ~/.cache/pip |
| 21 | + ~/.platformio/.cache |
| 22 | + key: ${{ runner.os }}-pio |
| 23 | + - uses: actions/setup-python@v4 |
| 24 | + with: |
| 25 | + python-version: "3.11" |
| 26 | + |
| 27 | + - name: Install PlatformIO Core |
| 28 | + run: pip install --upgrade platformio |
| 29 | + |
| 30 | + - name: Build PlatformIO Project |
| 31 | + run: pio run -d senseBox-bike-atrai-v2 |
| 32 | + |
| 33 | + - name: Create OTA update file |
| 34 | + run: | |
| 35 | + git clone https://github.com/arduino-libraries/ArduinoIoTCloud.git |
| 36 | +
|
| 37 | + pip install crccheck |
| 38 | +
|
| 39 | + cd ArduinoIoTCloud/extras/tools |
| 40 | +
|
| 41 | + python3 lzss.py --encode ${{ github.workspace }}/senseBox-bike-atrai-v2/.pio/build/sensebox_mcu_esp32s2/firmware.bin ${{ runner.temp }}/firmware.bin.lzss |
| 42 | + python3 bin2ota.py ESP32 $${{ runner.temp }}/firmware.bin.lzss ${{ runner.temp }}/firmware.ota |
| 43 | + mv ${{ runner.temp }}/firmware.ino.ota ${{ github.workspace }}/senseBox-bike-atrai-v2/.pio/build/sensebox_mcu_esp32s2/senseBox-bike-atrai-v2.bin.ota |
| 44 | + mv ${{ github.workspace }}/senseBox-bike-atrai-v2/.pio/build/sensebox_mcu_esp32s2/firmware.bin ${{ github.workspace }}/senseBox-bike-atrai-v2/.pio/build/sensebox_mcu_esp32s2/senseBox-bike-atrai-v2.bin |
| 45 | +
|
| 46 | + - name: Export binaries as artifacts |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: senseBox-bike-atrai-v2-artifacts |
| 50 | + path: ${{ github.workspace }} |
| 51 | + |
| 52 | + release: |
| 53 | + needs: build |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Download Firmware Files |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + path: release |
| 60 | + - name: Release Firmware |
| 61 | + uses: ncipollo/release-action@v1 |
| 62 | + if: startsWith(github.ref, 'refs/tags/') |
| 63 | + with: |
| 64 | + artifacts: "release/**/*.bin, release/**/*.ota" |
| 65 | + allowUpdates: true |
| 66 | + omitBodyDuringUpdate: true |
| 67 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments