Rename and restructure #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release PowerControlHub Firmware | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-esp32: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Arduino CLI | |
| uses: arduino/setup-arduino-cli@v1 | |
| - name: Configure Arduino CLI | |
| run: | | |
| arduino-cli config init | |
| arduino-cli config set board_manager.additional_urls https://espressif.github.io/arduino-esp32/package_esp32_index.json | |
| arduino-cli core update-index | |
| arduino-cli core install esp32:esp32 | |
| - name: Install required libraries | |
| run: | | |
| arduino-cli lib install "ArduinoJson" | |
| arduino-cli lib install "SerialCommandManager" | |
| arduino-cli lib install "SensorManager" | |
| arduino-cli lib install "SdFat" | |
| arduino-cli lib install "NextionControl" | |
| arduino-cli lib install "TinyGPSPlus" | |
| arduino-cli lib install "DS1302" | |
| - name: Generate FirmwareVersion.h | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| VERSION="${TAG#v}" | |
| IFS='.' read -r MAJOR MINOR PATCH BUILD <<< "$VERSION" | |
| printf "#pragma once\n#include <Arduino.h>\n\n// Generated by CI from tag %s - do not edit manually.\nconstexpr uint8_t FirmwareMajor = %s;\nconstexpr uint8_t FirmwareMinor = %s;\nconstexpr uint8_t FirmwarePatch = %s;\nconstexpr uint8_t FirmwareBuild = %s;\n" "$TAG" "$MAJOR" "$MINOR" "$PATCH" "$BUILD" > PowerControlHub/FirmwareVersion.h | |
| - name: Compile ESP32 firmware | |
| run: | | |
| arduino-cli compile \ | |
| --fqbn esp32:esp32:esp32 \ | |
| --output-dir PowerControlHub/build/esp32 \ | |
| PowerControlHub | |
| - name: Rename and checksum ESP32 firmware | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| SRC="PowerControlHub/build/esp32/PowerControlHub.ino.bin" | |
| DEST="PowerControlHub-esp32-${TAG}.bin" | |
| cp "$SRC" "$DEST" | |
| sha256sum "$DEST" | awk '{print $1}' > "PowerControlHub-esp32-${TAG}.sha256" | |
| - name: Upload ESP32 firmware to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| PowerControlHub-esp32-${{ github.ref_name }}.bin | |
| PowerControlHub-esp32-${{ github.ref_name }}.sha256 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-esp32s3: | |
| runs-on: ubuntu-latest | |
| needs: build-esp32 # optional, but keeps logs tidy | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Arduino CLI | |
| uses: arduino/setup-arduino-cli@v1 | |
| - name: Configure Arduino CLI | |
| run: | | |
| arduino-cli config init | |
| arduino-cli config set board_manager.additional_urls https://espressif.github.io/arduino-esp32/package_esp32_index.json | |
| arduino-cli core update-index | |
| arduino-cli core install esp32:esp32 | |
| - name: Install required libraries | |
| run: | | |
| arduino-cli lib install "ArduinoJson" | |
| arduino-cli lib install "SerialCommandManager" | |
| arduino-cli lib install "SensorManager" | |
| arduino-cli lib install "SdFat" | |
| arduino-cli lib install "DHT11" | |
| - name: Generate FirmwareVersion.h | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| VERSION="${TAG#v}" | |
| IFS='.' read -r MAJOR MINOR PATCH BUILD <<< "$VERSION" | |
| printf "#pragma once\n#include <Arduino.h>\n\n// Generated by CI from tag %s - do not edit manually.\nconstexpr uint8_t FirmwareMajor = %s;\nconstexpr uint8_t FirmwareMinor = %s;\nconstexpr uint8_t FirmwarePatch = %s;\nconstexpr uint8_t FirmwareBuild = %s;\n" "$TAG" "$MAJOR" "$MINOR" "$PATCH" "$BUILD" > PowerControlHub/FirmwareVersion.h | |
| - name: Compile ESP32-S3 firmware | |
| run: | | |
| arduino-cli compile \ | |
| --fqbn esp32:esp32:esp32s3 \ | |
| --output-dir PowerControlHub/build/esp32s3 \ | |
| PowerControlHub | |
| - name: Rename and checksum ESP32-S3 firmware | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| SRC="PowerControlHub/build/esp32s3/PowerControlHub.ino.bin" | |
| DEST="PowerControlHub-esp32s3-${TAG}.bin" | |
| cp "$SRC" "$DEST" | |
| sha256sum "$DEST" | awk '{print $1}' > "PowerControlHub-esp32s3-${TAG}.sha256" | |
| - name: Upload ESP32-S3 firmware to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| PowerControlHub-esp32s3-${{ github.ref_name }}.bin | |
| PowerControlHub-esp32s3-${{ github.ref_name }}.sha256 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |