From f94e6cd901fb62fa9b77ec5a4997347468596731 Mon Sep 17 00:00:00 2001 From: IgorYbema Date: Wed, 30 Sep 2026 20:02:06 +0000 Subject: [PATCH] CI: open a PR adding release binaries to binaries/ on tag builds On a v* tag build, copy the freshly built ESP32 and ESP8266 release binaries into binaries/model-type-{large,small}/ using the existing naming (HeishaMon.ino.esp32-.bin / HeishaMon.ino.d1-.bin plus .md5 files), update the latest release line in binaries/README.md and open a PR against main. main is protected, so a PR is used instead of a direct push. The binaries in binaries/ are then exactly the ones attached to the GitHub release. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CZw3KwurM2TJxfDAQWTAWi --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 520e9bc4..27050686 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,6 +13,7 @@ on: permissions: contents: write + pull-requests: write # release builds open a PR adding the binaries to binaries/ env: ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS: "http://arduino.esp8266.com/stable/package_esp8266com_index.json https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json" @@ -68,6 +69,7 @@ jobs: cd HeishaMon MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1` mv HeishaMon.ino.bin HeishaMon_ESP8266-${{ env.BUILD_TYPE }}-$MD5.bin + echo "MD5_ESP8266=$MD5" >> $GITHUB_ENV shell: bash - name: Compile Sketch for ESP32 @@ -78,6 +80,7 @@ jobs: cd HeishaMon MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1` mv HeishaMon.ino.bin HeishaMon_ESP32-${{ env.BUILD_TYPE }}-$MD5.bin + echo "MD5_ESP32=$MD5" >> $GITHUB_ENV shell: bash - name: Upload artifacts @@ -120,3 +123,29 @@ jobs: Commit: ${{ github.sha }} prerelease: true files: HeishaMon/HeishaMon_*.bin + + - name: Open PR adding release binaries to binaries/ + if: startsWith(github.ref, 'refs/tags/v') + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + BRANCH="release-binaries-$TAG" + # Work on a clean checkout of main, the tag checkout has a modified version.h + git fetch --depth=1 origin +refs/heads/main:refs/remotes/origin/main + git worktree add -b "$BRANCH" ../release-binaries origin/main + cp "HeishaMon/HeishaMon_ESP32-Release-$MD5_ESP32.bin" "../release-binaries/binaries/model-type-large/HeishaMon.ino.esp32-$TAG.bin" + echo -n "$MD5_ESP32" > "../release-binaries/binaries/model-type-large/HeishaMon.ino.esp32-$TAG.md5" + cp "HeishaMon/HeishaMon_ESP8266-Release-$MD5_ESP8266.bin" "../release-binaries/binaries/model-type-small/HeishaMon.ino.d1-$TAG.bin" + echo -n "$MD5_ESP8266" > "../release-binaries/binaries/model-type-small/HeishaMon.ino.d1-$TAG.md5" + cd ../release-binaries + sed -i "s/^The latest production release is .*\./The latest production release is $TAG./" binaries/README.md + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add binaries/ + git commit -m "release $TAG binaries" + git push origin "$BRANCH" + gh pr create --base main --head "$BRANCH" \ + --title "Release $TAG binaries" \ + --body "Adds the $TAG firmware built by release run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} to binaries/ and updates binaries/README.md." + shell: bash