|
| 1 | +name: Release Firmware on Label |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + |
| 7 | +jobs: |
| 8 | + release: |
| 9 | + if: github.event.pull_request.merged == true && |
| 10 | + contains(github.event.pull_request.labels.*.name, 'release') |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + |
| 20 | + - name: Install PlatformIO |
| 21 | + run: pip install platformio |
| 22 | + |
| 23 | + - name: Extract firmware version from config.h |
| 24 | + id: firmware_version |
| 25 | + run: | |
| 26 | + VERSION=$(grep -oP '#define\s+VERSION\s+"\K[^"]+' src/config.h) |
| 27 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 28 | + echo "Firmware version: $VERSION" |
| 29 | +
|
| 30 | + - name: Extract filesystem version |
| 31 | + id: fs_version |
| 32 | + run: | |
| 33 | + FS_VERSION=$(cat data/version.txt | tr -d '\n') |
| 34 | + echo "FS_VERSION=$FS_VERSION" >> $GITHUB_ENV |
| 35 | + echo "Filesystem version: $FS_VERSION" |
| 36 | +
|
| 37 | + - name: Build firmware |
| 38 | + run: pio run -e ESP32-S3 |
| 39 | + |
| 40 | + - name: Build filesystem |
| 41 | + run: pio run -e ESP32-S3 -t buildfs |
| 42 | + |
| 43 | + - name: Rename binaries with version |
| 44 | + run: | |
| 45 | + mkdir release |
| 46 | + cp .pio/build/ESP32-S3/firmware.bin release/firmware-${VERSION}.bin |
| 47 | + cp .pio/build/ESP32-S3/littlefs.bin release/filesystem-${FS_VERSION}.bin |
| 48 | +
|
| 49 | + - name: Create GitHub release |
| 50 | + uses: softprops/action-gh-release@v1 |
| 51 | + with: |
| 52 | + tag_name: ${{ env.VERSION }} |
| 53 | + name: Release ${{ env.VERSION }} |
| 54 | + files: release/* |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments