Update README.md #123
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 OpenEarable v2 Firmware | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: ["main"] | |
| push: | |
| branches: ["main"] | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Clone the repo to a subdirectory, so we can initialize the Zephyr | |
| # workspace in the parent directory. | |
| path: zephyr-workspace/open-earable-v2 | |
| - name: Cache/Install APT Packages | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: ccache git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 | |
| version: 1.0 | |
| execute_install_scripts: true | |
| - name: Cache PIP Packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install West | |
| run: | | |
| pip3 install west | |
| - name: Install Zephyr SDK | |
| run: | | |
| wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.4/zephyr-sdk-0.16.4_linux-x86_64_minimal.tar.xz | |
| tar xf zephyr-sdk-0.16.4_linux-x86_64_minimal.tar.xz -C ~/ | |
| ~/zephyr-sdk-0.16.4/setup.sh -c -t arm-zephyr-eabi | |
| - name: Initialize Zephyr Workspace | |
| # Set up the Zephyr workspace and install the Python dependencies | |
| run: | | |
| cd zephyr-workspace | |
| west init -l open-earable-v2 | |
| west update --narrow -o=--depth=1 | |
| pip3 install -r zephyr/scripts/requirements.txt | |
| - name: Register Custom Boards | |
| # Registers our custom boards in the Zephyr build system | |
| run: | | |
| mkdir -p $(pwd)/workflow-board-temp | |
| cp -R $(pwd)/zephyr-workspace/open-earable-v2/boards $(pwd)/workflow-board-temp/boards | |
| # Merge teco dir (if it exists) to arm dir (assuming the boards are for arm) | |
| mkdir -p $(pwd)/workflow-board-temp/boards/arm # Create arm dir if not exist | |
| cp -R -f $(pwd)/workflow-board-temp/boards/teco/* $(pwd)/workflow-board-temp/boards/arm/ || true | |
| rm -f -R $(pwd)/workflow-board-temp/boards/teco | |
| # Copy merged dir | |
| cp -R -f $(pwd)/workflow-board-temp/boards/* $(pwd)/zephyr-workspace/zephyr/boards | |
| - name: Cache ~/.cache/ccache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/ccache | |
| key: ccache-v1-${{ runner.os }}-${{ hashFiles('zephyr-workspace/open-earable-v2/west.yml') }} | |
| restore-keys: | | |
| ccache-v1-${{ runner.os }}- | |
| - name: Build Project | |
| run: | | |
| cd zephyr-workspace | |
| # zero ccache statistics | |
| ccache -z | |
| # `openearable_v2/nrf5340/cpuapp` is what we see in the terminal when building | |
| # using VSCode + Nordic Plugins | |
| west build \ | |
| --board openearable_v2/nrf5340/cpuapp \ | |
| --pristine=always open-earable-v2 \ | |
| -- -DFILE_SUFFIX="fota" | |
| # print detailed ccache statistics | |
| ccache -sv | |
| - name: Check And Prepare Build Output | |
| run: | | |
| mkdir -p $(pwd)/workflow-board-temp/build-output | |
| cp $(pwd)/zephyr-workspace/build/ipc_radio/zephyr/zephyr.elf $(pwd)/workflow-board-temp/build-output/openearable_v2_firmware.elf | |
| cp $(pwd)/zephyr-workspace/build/dfu_application.zip $(pwd)/workflow-board-temp/build-output/openearable_v2_fota.zip | |
| (cd $(pwd)/workflow-board-temp/build-output && unzip openearable_v2_fota.zip -d openearable_v2_fota && rm openearable_v2_fota.zip) | |
| ls $(pwd)/workflow-board-temp/build-output/openearable_v2_firmware.elf | |
| echo "" | |
| echo "Fota dir:" | |
| ls $(pwd)/workflow-board-temp/build-output/openearable_v2_fota | |
| - name: Upload Build Artifact (Firmware) | |
| uses: actions/upload-artifact@v4 | |
| id: artifact-upload-step-1 | |
| with: | |
| name: openearable_v2_firmware.elf | |
| path: workflow-board-temp/build-output/openearable_v2_firmware.elf | |
| - name: Upload Build Artifact (FOTA build) | |
| uses: actions/upload-artifact@v4 | |
| id: artifact-upload-step-2 | |
| with: | |
| name: openearable_v2_fota.zip | |
| path: workflow-board-temp/build-output/openearable_v2_fota/ | |
| - name: PR Comment with File | |
| if: github.event_name == 'pull_request' | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| message: | | |
| Build output available: | |
| [openearable_v2_firmware.elf.zip](${{ steps.artifact-upload-step-1.outputs.artifact-url }}) | |
| [openearable_v2_fota.zip](${{ steps.artifact-upload-step-2.outputs.artifact-url }}) |