From 13b4ce92681b21d2d6478dd65c20c7cb2dd27a7d Mon Sep 17 00:00:00 2001 From: Pirata <104320209+bmorcelli@users.noreply.github.com> Date: Sun, 5 May 2024 05:26:37 -0300 Subject: [PATCH] Create build.yml --- .github/workflows/build.yml | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..c17b9de8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,100 @@ +name: Test-build + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + # - feature/cicd-adjusts + +jobs: + build_and_release: + name: Build for tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install dependencies + run: pip install requests esptool + + - name: Install PlatformIO Core + run: | + pip install platformio + platformio update + + - name: Build Project + run: | + platformio run + + - name: Merge output binaries files + run: | + esptool.py --chip esp32 merge_bin -o .pio/build/m5stack-cplus1_1/release.bin --flash_mode dio --flash_size 4MB 0x1000 .pio/build/m5stack-cplus1_1/bootloader.bin 0x8000 .pio/build/m5stack-cplus1_1/partitions.bin 0x10000 .pio/build/m5stack-cplus1_1/firmware.bin + esptool.py --chip esp32 merge_bin -o .pio/build/m5stack-cplus2/release.bin --flash_mode dio --flash_size 8MB 0x1000 .pio/build/m5stack-cplus2/bootloader.bin 0x8000 .pio/build/m5stack-cplus2/partitions.bin 0x10000 .pio/build/m5stack-cplus2/firmware.bin + esptool.py --chip esp32s3 merge_bin -o .pio/build/m5stack-cardputer/release.bin --flash_mode dio --flash_size 8MB 0x0000 .pio/build/m5stack-cardputer/bootloader.bin 0x8000 .pio/build/m5stack-cardputer/partitions.bin 0x10000 .pio/build/m5stack-cardputer/firmware.bin + + - name: Rename release.bin files + run: | + for file in $(find .pio/build/**/ -name 'release.bin'); do + version=$(echo ${{ github.run_number }}) + env=$(basename $(dirname "$file")) + new_name="Bruce_${env}_v0.0.$version.bin" + mv "$file" "$(dirname "$file")/$new_name" + done + chmod +r .pio/build/**/Bruce*.bin + ls .pio/build/**/Bruce*.bin + if: github.event_name != 'pull_request' + + - name: Upload Binaries + id: upload_binaries_Cplus + uses: actions/upload-artifact@v3 + with: + path: .pio/build/m5stack-cplus1_1/Bruce*.bin + if: github.event_name != 'pull_request' + + - name: Upload Binaries + id: upload_binaries_Cplus2 + uses: actions/upload-artifact@v3 + with: + path: .pio/build/m5stack-cplus2/Bruce*.bin + if: github.event_name != 'pull_request' + + - name: Upload Binaries_Card + id: upload_binaries + uses: actions/upload-artifact@v3 + with: + path: .pio/build/m5stack-cardputer/Bruce*.bin + if: github.event_name != 'pull_request' + + #- name: Create Release + # id: create_release + # uses: actions/create-release@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.RELEASES_TOKEN }} + # with: + # tag_name: v0.0.${{ github.run_number }} + # release_name: v0.0.${{ github.run_number }} + # draft: true + # prerelease: false + # body: | + # Release automatically generated by CI/CD workflow. + # if: github.event_name != 'pull_request' + + #- name: Upload Binaries Release Assets + # run: | + # for file in $(find .pio/build/** -name 'ESP_Web2Sd-Mgr*.bin'); do + # echo "Uploading $file" + # curl \ + # -X POST \ + # --data-binary @"$file" \ + # -H "Authorization: Bearer ${{ secrets.RELEASES_TOKEN }}" \ + # -H "Content-Type: application/octet-stream" \ + # "${{ steps.create_release.outputs.upload_url }}=$(basename $file)" + # done