diff --git a/.github/workflows/build_release_bins.yml b/.github/workflows/build_release_bins.yml index aafaecd..1b6efd1 100644 --- a/.github/workflows/build_release_bins.yml +++ b/.github/workflows/build_release_bins.yml @@ -3,27 +3,19 @@ on: push: branches: - "master" + - "main" pull_request: branches: - "master" + - "main" workflow_dispatch: jobs: build: strategy: fail-fast: false - matrix: - target_name: [ - esp32AIThinker, - esp32M5Stack, - esp32Cam, - esp_eye, - wrover, - ] - target_build_type: [ - "", - _release, - _OTA, - ] + matrix: + target_name: [esp32AIThinker, esp32M5Stack, esp32Cam, esp_eye, wrover] + target_build_type: ["", _release, _OTA] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -40,78 +32,84 @@ jobs: with: path: ~/.platformio key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + restore-keys: | + ${{ runner.os }}-pio- - name: Setup Python install uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: "3.x" - name: Install PlatformIO with Pip run: | + python -m pip install --upgrade pip + pip install distro pip install --upgrade platformio + pio upgrade --dev + pio pkg update --global + - name: Update build command + working-directory: ./ESP + run: | + sed -i '/\[env\]/p; s/\[env\]/upload_protocol = custom/' platformio.ini - name: Build OpenIris Firmware working-directory: ./ESP run: | + export OPENIRIS_CI_BUILD=1 + mkdir build + mkdir build/${{ matrix.target_name }}${{ matrix.target_build_type }} + echo "::group::platformio.ini" + cat platformio.ini + echo "::endgroup::" + echo "::group::pio run" pio run --environment ${{ matrix.target_name }}${{ matrix.target_build_type }} - #- name: Archive Version File - # uses: actions/upload-artifact@v3 - # with: - # name: version - # path: ./ESP/tools/version.txt + echo "::endgroup::" + unzip -l './build/${{ matrix.target_name }}${{ matrix.target_build_type }}/*.zip' - name: Archive Firmware name File # create an environment variable with the name of the firmware file by catting the firmware_name.txt file run: | echo "FIRMWARE_NAME=$(cat ./ESP/tools/firmware_name.txt)" >> $GITHUB_ENV - - name: Archive Firmware Files + - name: Archive Firmware Binaries uses: actions/upload-artifact@v3 - with: + with: name: ${{ matrix.target_name }}${{ matrix.target_build_type }}-firmware - path: "./ESP/.pio/build/${{ matrix.target_name }}${{ matrix.target_build_type }}/${{ env.FIRMWARE_NAME }}.bin" + #path: "./ESP/.pio/build/${{ matrix.target_name }}${{ matrix.target_build_type }}/${{ env.FIRMWARE_NAME }}.bin" + path: "./ESP/build/${{ matrix.target_name }}${{ matrix.target_build_type }}/${{ env.FIRMWARE_NAME }}.zip" + retention-days: 5 if-no-files-found: error release-openiris: runs-on: ubuntu-latest needs: [build] steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create Directory - run: mkdir -p build - - name: Download Firmware Files - uses: actions/download-artifact@v2 - with: - path: build/ - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install -g conventional-changelog-conventionalcommits - - run: npm install -g semantic-release@v19.0.5 - - run: npm install -g @semantic-release/exec - - run: npm install -g @semantic-release/git - - run: npm install -g @semantic-release/release-notes-generator - - run: npm install -g @semantic-release/changelog - - run: npm install -g @semantic-release/github - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: semantic-release + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create Directory + run: mkdir -p build + - name: Download Firmware Files + uses: actions/download-artifact@v2 + with: + path: build/ + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm install -g conventional-changelog-conventionalcommits + - run: npm install -g semantic-release@v19.0.5 + - run: npm install -g @semantic-release/exec + - run: npm install -g @semantic-release/git + - run: npm install -g @semantic-release/release-notes-generator + - run: npm install -g @semantic-release/changelog + - run: npm install -g @semantic-release/github + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: semantic-release cleanup: strategy: fail-fast: false - matrix: - target_name: [ - esp32AIThinker, - esp32M5Stack, - esp32Cam, - esp_eye, - wrover, - ] - target_build_type: [ - "", - _release, - _OTA, - ] + matrix: + target_name: [esp32AIThinker, esp32M5Stack, esp32Cam, esp_eye, wrover] + target_build_type: ["", _release, _OTA] name: Cleanup actions needs: - release-openiris @@ -121,4 +119,4 @@ jobs: - name: "♻️ remove build artifacts" uses: geekyeggo/delete-artifact@v1 with: - name: ${{ matrix.target_name }}${{ matrix.target_build_type }}-firmware \ No newline at end of file + name: ${{ matrix.target_name }}${{ matrix.target_build_type }}-firmware diff --git a/.releaserc b/.releaserc index 3f569de..0e794d9 100644 --- a/.releaserc +++ b/.releaserc @@ -158,7 +158,7 @@ "addReleases": "bottom", "assets": [ { - "path": "./build/**/*.bin" + "path": "./build/**/*.zip" } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 21acd1c..6c18ef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,63 @@ [![semantic versioning](https://img.shields.io/badge/semantic%20versioning-2.0.0-green.svg)](https://semver.org) > All notable changes to this project will be documented in this file +## [1.4.0-create-zip.6](https://github.com/lorow/OpenIris/compare/v1.4.0-create-zip.5...v1.4.0-create-zip.6) (2023-02-02) + + +### 🍕 Features + +* add detection of environment variable ([ca8080e](https://github.com/lorow/OpenIris/commit/ca8080e7f1727d273f4d135414a1e17d11eaddc8)) + +## [1.4.0-create-zip.5](https://github.com/lorow/OpenIris/compare/v1.4.0-create-zip.4...v1.4.0-create-zip.5) (2023-02-02) + + +### 🧑‍💻 Code Refactoring + +* cleanup script ([a2202d6](https://github.com/lorow/OpenIris/commit/a2202d6288a76ab195d7cfb8fc14245d1a4715f9)) + +## [1.4.0-create-zip.4](https://github.com/lorow/OpenIris/compare/v1.4.0-create-zip.3...v1.4.0-create-zip.4) (2023-02-01) + + +### 🐛 Bug Fixes + +* firmware binary bundling bug ([6004cdf](https://github.com/lorow/OpenIris/commit/6004cdf9b7c97d7f604f62077751926919059774)) + +## [1.4.0-create-zip.3](https://github.com/lorow/OpenIris/compare/v1.4.0-create-zip.2...v1.4.0-create-zip.3) (2023-01-31) + + +### 🍕 Features + +* testing createzip script ([1a3ba1b](https://github.com/lorow/OpenIris/commit/1a3ba1b47ff9b948e69e1ce03119fe1aea65e62e)) +* testing createzip script ([3094c29](https://github.com/lorow/OpenIris/commit/3094c29d1fde5d3b16dd7150f9784e07d0093cc3)) +* testing createzip script ([af89d4d](https://github.com/lorow/OpenIris/commit/af89d4d38062947fef578970787d1b90e3cea188)) +* testing createzip script ([35bb0f2](https://github.com/lorow/OpenIris/commit/35bb0f2935832b2e65a3f0870c8f084daee5fde1)) +* testing createzip script ([ab196c5](https://github.com/lorow/OpenIris/commit/ab196c56ac61932144e27d69b181e7c0b25aedc6)) +* testing createzip script ([c63e223](https://github.com/lorow/OpenIris/commit/c63e22300215103321b4be6821d9f3902c9dd128)) +* testing createzip script ([9d3fd65](https://github.com/lorow/OpenIris/commit/9d3fd65d6f13f22f522d840ce50dad74663891c2)) +* testing createzip script ([ef652f4](https://github.com/lorow/OpenIris/commit/ef652f4a923f59134a697ed6dc0228a31b978826)) +* testing createzip script ([bcef340](https://github.com/lorow/OpenIris/commit/bcef34014d37b3b974bdd8209b67ae6e9f30cfaf)) +* testing createzip script ([8d4d5cc](https://github.com/lorow/OpenIris/commit/8d4d5cc1705628c38b0046201b4ff146f9ba9e20)) +* testing createzip script ([fd6ccdc](https://github.com/lorow/OpenIris/commit/fd6ccdcae140dd2fdfd8a4b439cba84282a9832c)) + +## [1.4.0-create-zip.2](https://github.com/lorow/OpenIris/compare/v1.4.0-create-zip.1...v1.4.0-create-zip.2) (2023-01-31) + + +### 🍕 Features + +* testing createzip script ([fb9c35d](https://github.com/lorow/OpenIris/commit/fb9c35dda9b8447e74673ffb7ed793bd57d9c39e)) + +## [1.4.0-create-zip.1](https://github.com/lorow/OpenIris/compare/v1.3.0...v1.4.0-create-zip.1) (2023-01-31) + + +### 🍕 Features + +* testing craetezip script ([7db8063](https://github.com/lorow/OpenIris/commit/7db8063291e24926929450ebf8b40778f82a9d97)) +* testing craetezip script ([2584e37](https://github.com/lorow/OpenIris/commit/2584e37ffacb2aa2ed915842c03657b85c4dd881)) +* testing craetezip script ([174e9ae](https://github.com/lorow/OpenIris/commit/174e9aebe74fdff6fdbe88cf6555c6d1d2ba8555)) +* testing craetezip script ([0d2b56e](https://github.com/lorow/OpenIris/commit/0d2b56e62fbd4c7694ee40a06ccfa2ac0dba8eab)) +* testing createzip script ([c7d3ed7](https://github.com/lorow/OpenIris/commit/c7d3ed7b79d4da68052b08bc9c9489a7925883b7)) +* testing createzip script ([4eb4758](https://github.com/lorow/OpenIris/commit/4eb4758147e021e7e2447eb98a663bd8b4d5de3e)) + ## [1.3.0](https://github.com/lorow/OpenIris/compare/v1.2.0...v1.3.0) (2023-01-31) diff --git a/ESP/lib/library.json b/ESP/lib/library.json index 8a2aa15..5f8dc60 100644 --- a/ESP/lib/library.json +++ b/ESP/lib/library.json @@ -20,7 +20,7 @@ "include": "/lib/src" }, "dependencies": {}, - "version": "1.3.0", + "version": "1.4.0", "frameworks": "arduino", "platforms": "espressif32" -} \ No newline at end of file +} diff --git a/ESP/lib/src/data/StateManager/StateManager.cpp b/ESP/lib/src/data/StateManager/StateManager.cpp index ec64375..427faad 100644 --- a/ESP/lib/src/data/StateManager/StateManager.cpp +++ b/ESP/lib/src/data/StateManager/StateManager.cpp @@ -6,4 +6,4 @@ StateManager webServerStateManager; StateManager mdnsStateManager; StateManager cameraStateManager; StateManager ledStateManager; -StateManager streamStateManager; \ No newline at end of file +StateManager streamStateManager; diff --git a/ESP/lib/src/data/StateManager/StateManager.hpp b/ESP/lib/src/data/StateManager/StateManager.hpp index 039563e..c163582 100644 --- a/ESP/lib/src/data/StateManager/StateManager.hpp +++ b/ESP/lib/src/data/StateManager/StateManager.hpp @@ -149,4 +149,4 @@ extern StateManager cameraStateManager; extern StateManager ledStateManager; extern StateManager streamStateManager; -#endif // STATEMANAGER_HPP \ No newline at end of file +#endif // STATEMANAGER_HPP diff --git a/ESP/platformio.ini b/ESP/platformio.ini index 208be51..d834133 100644 --- a/ESP/platformio.ini +++ b/ESP/platformio.ini @@ -68,4 +68,6 @@ lib_deps = https://github.com/me-no-dev/AsyncTCP.git build_type = debug -extra_scripts = pre:tools/customname.py +extra_scripts = + pre:tools/customname.py + post:tools/createzip.py diff --git a/ESP/tools/createzip.py b/ESP/tools/createzip.py new file mode 100644 index 0000000..5dbb24e --- /dev/null +++ b/ESP/tools/createzip.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +Import("env") + +import sys +import os +from ntpath import basename +from zipfile import ZipFile +import json + + +def createZip(source, target, env): + if os.getenv("OPENIRIS_CI_BUILD", False): + if sys.platform.lower().startswith(("ubuntu", "linux")): + print("Program has been built, creating zip archive!") + program_path = target[0].get_abspath() + + array_args = [env["FLASH_EXTRA_IMAGES"]] + + for offset, image in env["FLASH_EXTRA_IMAGES"]: + print("\nImage: %s" % str(image)) + array_args.extend([str(offset), str(image)]) + + array_args.append(env["ESP32_APP_OFFSET"]) + array_args.append(program_path) + + n = 2 + partitions_arg = array_args[1:] + print(f"partitions_args: {partitions_arg}") + partitions = final = [ + partitions_arg[i * n : (i + 1) * n] + for i in range((len(partitions_arg) + n - 1) // n) + ] + print(f"partitions: {partitions}") + file_name = "./build/{0}/{1}.zip".format( + str(env["PIOENV"]), env["PROGNAME"] + ) + with ZipFile(file_name, "w") as archive: + print('\nCreating "' + archive.filename + '"', end="\n") + parts = [] + for [offset, path] in partitions: + filename = basename(path) + archive.write(path, filename) + partition = { + "path": filename, + "offset": int(offset, 16), + } + parts.append(partition) + manifest = { + "chipFamily": "ESP32", + "parts": parts, + } + archive.writestr("manifest.json", json.dumps(manifest)) + else: + print("Not running on Linux, skipping zip creation") + else: + print("CI build not detected, skipping zip creation") + + +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", createZip)