Build binary #348
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: Build binary | |
| on: | |
| push: | |
| branches-ignore: | |
| - main # never run on plain main pushes | |
| tags: | |
| - '**' # but DO run on any tag (including tags on main) | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 2 * * *' # nightly at 2am UTC | |
| permissions: | |
| contents: write | |
| 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" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set version env var | |
| run: echo "GIT_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Set build type env var | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "BUILD_TYPE=Release" >> $GITHUB_ENV | |
| echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
| elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "BUILD_TYPE=Nightly" >> $GITHUB_ENV | |
| echo "VERSION=Nightly-${{ env.GIT_SHORT_SHA }}" >> $GITHUB_ENV | |
| else | |
| echo "BUILD_TYPE=Alpha" >> $GITHUB_ENV | |
| echo "VERSION=Alpha-${{ env.GIT_SHORT_SHA }}" >> $GITHUB_ENV | |
| fi | |
| shell: bash | |
| - name: Update version.h | |
| if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| cd HeishaMon && sed -i 's/#define HEISHAMON_VERSION .*/#define HEISHAMON_VERSION "${{ env.VERSION }}"/' version.h && cat version.h | |
| shell: bash | |
| - name: Setup Arduino CLI | |
| uses: arduino/setup-arduino-cli@v2 | |
| - name: Install platform | |
| run: | | |
| arduino-cli core update-index | |
| arduino-cli core install esp8266:esp8266 | |
| arduino-cli core install esp32:esp32@3.0.7 | |
| - name: Install dependencies | |
| run: arduino-cli lib install ringbuffer pubsubclient arduinojson dallastemperature onewire "Adafruit NeoPixel" | |
| - name: Fix Onewire lib for ESP32-3.0.0 | |
| run: | | |
| sed -i '/#include <driver\/rtc_io\.h>/a\ #include <soc\/gpio_struct\.h>' \ | |
| /home/runner/Arduino/libraries/OneWire/util/OneWire_direct_gpio.h | |
| - name: Compile Sketch for ESP8266 | |
| run: cd HeishaMon && arduino-cli compile --output-dir . --fqbn=esp8266:esp8266:d1_mini:xtal=160,vt=flash,ssl=basic,mmu=3216,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 --warnings=none --verbose HeishaMon.ino | |
| - name: Add MD5 checksum to ESP8266 binary | |
| run: | | |
| cd HeishaMon | |
| MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1` | |
| mv HeishaMon.ino.bin HeishaMon_ESP8266-${{ env.BUILD_TYPE }}-$MD5.bin | |
| shell: bash | |
| - name: Compile Sketch for ESP32 | |
| run: cd HeishaMon && arduino-cli compile --output-dir . --fqbn=esp32:esp32:esp32s3:CDCOnBoot=cdc,PSRAM=enabled,PartitionScheme=min_spiffs --warnings=none --verbose HeishaMon.ino | |
| - name: Add MD5 checksum to ESP32 binary | |
| run: | | |
| cd HeishaMon | |
| MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1` | |
| mv HeishaMon.ino.bin HeishaMon_ESP32-${{ env.BUILD_TYPE }}-$MD5.bin | |
| shell: bash | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Heishamon-firmware-${{ env.BUILD_TYPE }}-${{ env.GIT_SHORT_SHA }} | |
| path: | | |
| HeishaMon/HeishaMon_*.bin | |
| HeishaMon/HeishaMon.ino.map | |
| - name: Delete old nightly assets | |
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') | |
| run: | | |
| gh release view nightly --json assets --jq '.assets[].name' | \ | |
| xargs -I{} gh release delete-asset nightly {} --yes || true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| - name: Publish nightly release | |
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: nightly | |
| name: "Nightly build (${{ env.GIT_SHORT_SHA }})" | |
| body: | | |
| Automated nightly build from `main` branch. | |
| Commit: ${{ github.sha }} | |
| Built: ${{ github.run_id }} | |
| prerelease: true | |
| files: HeishaMon/HeishaMon_*.bin | |
| - name: Publish release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: "Release ${{ github.ref_name }}" | |
| body: | | |
| Release ${{ github.ref_name }} | |
| Commit: ${{ github.sha }} | |
| prerelease: true | |
| files: HeishaMon/HeishaMon_*.bin |