Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 53 additions & 11 deletions .github/workflows/build_firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Build OpenEarable v2 Firmware

on:
workflow_call:
inputs:
checkout_ref:
required: false
type: string
pull_request: {}
push:
branches:
Expand All @@ -22,43 +26,79 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
env:
ZEPHYR_SDK_VERSION: 0.17.0
ZEPHYR_SDK_PATH: /home/runner/zephyr-sdk-0.17.0
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
ref: ${{ inputs.checkout_ref || github.sha }}

- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Cache/Install APT Packages
uses: awalsh128/cache-apt-pkgs-action@latest
uses: awalsh128/cache-apt-pkgs-action@v1.5.3
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
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('zephyr-workspace/open-earable-v2/west.yml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install West
run: |
pip3 install west
python3 -m pip install --user west
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- name: Cache Zephyr SDK
id: cache-zephyr-sdk
uses: actions/cache@v4
with:
path: ${{ env.ZEPHYR_SDK_PATH }}
key: zephyr-sdk-${{ runner.os }}-${{ env.ZEPHYR_SDK_VERSION }}

- name: Install Zephyr SDK
if: steps.cache-zephyr-sdk.outputs.cache-hit != 'true'
run: |
wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz
tar xf zephyr-sdk-0.17.0_linux-x86_64_minimal.tar.xz -C ~/
~/zephyr-sdk-0.17.0/setup.sh -c -t arm-zephyr-eabi
wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz -C ~/

- name: Set Up Zephyr SDK
run: |
"${ZEPHYR_SDK_PATH}/setup.sh" -c -t arm-zephyr-eabi

- name: Cache Zephyr Workspace
uses: actions/cache@v4
with:
path: |
zephyr-workspace/.west
zephyr-workspace/bootloader
zephyr-workspace/modules
zephyr-workspace/nrf
zephyr-workspace/nrfxlib
zephyr-workspace/tools
zephyr-workspace/zephyr
key: west-workspace-v1-${{ runner.os }}-${{ hashFiles('zephyr-workspace/open-earable-v2/west.yml') }}

- name: Initialize Zephyr Workspace
# Set up the Zephyr workspace and install the Python dependencies
run: |
cd zephyr-workspace
west init -l open-earable-v2
if [ ! -d .west ]; then
west init -l open-earable-v2
fi
west update --narrow -o=--depth=1
pip3 install -r zephyr/scripts/requirements.txt

Expand All @@ -77,7 +117,7 @@ jobs:
cp -R -f $(pwd)/workflow-board-temp/boards/* $(pwd)/zephyr-workspace/zephyr/boards

- name: Cache ~/.cache/ccache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-v1-${{ runner.os }}-${{ hashFiles('zephyr-workspace/open-earable-v2/west.yml') }}
Expand All @@ -103,21 +143,23 @@ jobs:
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)

- 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
retention-days: 7

- 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/
path: workflow-board-temp/build-output/openearable_v2_fota.zip
retention-days: 7
compression-level: 0

- name: PR Comment with File
if: github.event_name == 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease_open_pr_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
rm -rf "$out"
continue
fi
(cd "$out/fota" && zip -r "../openearable_v2_fota.zip" .)
mv "$out/fota/openearable_v2_fota.zip" "$out/openearable_v2_fota.zip"
mv "$out/elf/openearable_v2_firmware.elf" "$out/openearable_v2_firmware.elf"
rm -rf "$out/elf" "$out/fota"

Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/release_firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,37 @@ permissions:
jobs:
build:
uses: ./.github/workflows/build_firmware.yaml
with:
checkout_ref: refs/tags/${{ inputs.release_tag }}

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Create Directory for Release Assets
run: mkdir -p release-assets

- name: Download Firmware Artifact (Firmware)
uses: actions/download-artifact@v4
with:
name: openearable_v2_firmware.elf

- name: Create Directory for FOTA
run: mkdir -p openearable_v2_fota
path: ./release-assets

- name: Download Firmware Artifact (FOTA)
uses: actions/download-artifact@v4
with:
name: openearable_v2_fota.zip
path: ./openearable_v2_fota

- name: Zip FOTA files again
run: |
# Pack the FOTA files into a zip file
# Downloading it unpacked the zip
ls openearable_v2_fota
(cd "openearable_v2_fota" && ls && zip -r ../openearable_v2_fota.zip *)
path: ./release-assets

- name: Create Github Release & Upload Firmware + FOTA
if: startsWith(github.ref, 'refs/tags/${{ inputs.release_tag }}')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.release_tag }}
name: ${{ inputs.release_name || inputs.release_tag }}
draft: false
prerelease: false
files: |
openearable_v2_firmware.elf
openearable_v2_fota.zip
release-assets/openearable_v2_firmware.elf
release-assets/openearable_v2_fota.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading