Merge pull request #45 from NabuCasa/update-matter-v1.1-ref #76
This file contains 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 and Publish Matter Example firmware | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '.github/workflows/build.yaml' | |
- '**.patch' | |
- '**/sdkconfig.defaults' | |
pull_request: | |
paths: | |
- '.github/workflows/build.yaml' | |
- '**.patch' | |
- '**/sdkconfig.defaults' | |
workflow_dispatch: | |
jobs: | |
# Inspired by .github/workflows/examples-esp32.yaml | |
build: | |
name: Build ${{ matrix.firmware.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
firmware: | |
- { | |
"name": "lighting-app-esp32-c3", | |
"dir": "lighting-app-example/esp32-c3/", | |
"root": "examples/lighting-app/esp32/", | |
"appbin": "chip-lighting-app.bin", | |
"idf_target": "esp32c3", | |
"chip_ref": "v1.1.0.2" | |
} | |
- { | |
"name": "lighting-app-esp32-atom-lite", | |
"dir": "lighting-app-example/esp32-atom-lite/", | |
"root": "examples/lighting-app/esp32/", | |
"appbin": "chip-lighting-app.bin", | |
"idf_target": "esp32", | |
"chip_ref": "v1.1.0.2" | |
} | |
- { | |
"name": "lighting-app-esp32-c3-m5stamp", | |
"dir": "lighting-app-example/esp32-c3-m5stamp/", | |
"root": "examples/lighting-app/esp32/", | |
"appbin": "chip-lighting-app.bin", | |
"idf_target": "esp32c3", | |
"chip_ref": "v1.1.0.2" | |
} | |
- { | |
"name": "light-switch-app-esp32-c3", | |
"dir": "light-switch-app-example/esp32-c3/", | |
"root": "examples/light-switch-app/esp32/", | |
"appbin": "chip-light-switch-app.bin", | |
"idf_target": "esp32c3", | |
"chip_ref": "v1.1.0.2" | |
} | |
- { | |
"name": "all-clusters-app-esp32-m5-basic-core", | |
"dir": "all-clusters-app-example/esp32-m5-basic-core/", | |
"root": "examples/all-clusters-app/esp32/", | |
"appbin": "chip-all-clusters-app.bin", | |
"idf_target": "esp32", | |
"chip_ref": "v1.1.0.2" | |
} | |
container: | |
image: connectedhomeip/chip-build-esp32:0.7.0 | |
outputs: | |
git-hash: ${{ steps.git-version.outputs.hash }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout CHIP repository | |
uses: actions/checkout@v4 | |
with: | |
repository: project-chip/connectedhomeip | |
ref: ${{ matrix.firmware.chip_ref }} | |
submodules: true | |
path: connectedhomeip | |
# Fixup for Matter v1.1 (see https://github.com/project-chip/connectedhomeip/pull/28507/files) | |
- name: Fixup GdbGui requirement | |
run: perl -i -pe 's/^gdbgui==/# gdbgui==/' /opt/espressif/esp-idf/requirements.txt | |
- name: Apply global patches | |
shell: bash | |
run: | | |
cd connectedhomeip | |
for patch in ../*.patch; do | |
patch -p1 < "${patch}" | |
done | |
- name: Get firmware git hash | |
run: | | |
ghash=$(git -C connectedhomeip rev-parse --short HEAD) | |
echo "hash=${ghash}" >> $GITHUB_OUTPUT | |
id: git-version | |
- name: Build | |
shell: bash | |
run: | | |
cd connectedhomeip | |
scripts/checkout_submodules.py --shallow --platform esp32 | |
for patch in ../${{ matrix.firmware.dir }}*.patch; do | |
patch -p1 < "${patch}" | |
done | |
source "$IDF_PATH/export.sh" | |
source scripts/activate.sh | |
root="${{ matrix.firmware.root }}" | |
rm -f "$root"/sdkconfig | |
cp "../${{ matrix.firmware.dir }}/sdkconfig.defaults" "${root}" | |
( | |
cd "$root" | |
sed -i "s/CONFIG_DEVICE_SOFTWARE_VERSION=.*/CONFIG_DEVICE_SOFTWARE_VERSION=\"${{ steps.git-version.outputs.hash }}\"/" sdkconfig.defaults | |
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults" set-target "${{ matrix.firmware.idf_target }}" build | |
) | |
mkdir -p ../deploy/${{ matrix.firmware.dir }} | |
cp ${{ matrix.firmware.root }}/build/${{ matrix.firmware.appbin }} ../deploy/${{ matrix.firmware.dir }} | |
cp ${{ matrix.firmware.root }}/build/bootloader/bootloader.bin ../deploy/${{ matrix.firmware.dir }} | |
cp ${{ matrix.firmware.root }}/build/partition_table/partition-table.bin ../deploy/${{ matrix.firmware.dir }} | |
cp ${{ matrix.firmware.root }}/build/ota_data_initial.bin ../deploy/${{ matrix.firmware.dir }} | |
- name: Upload artifacts | |
uses: actions/[email protected] | |
with: | |
name: ${{ matrix.firmware.name }} | |
path: deploy | |
publish: | |
name: Publish new firmware and website to GitHub Pages | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
permissions: | |
contents: write | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
path: artifacts/ | |
- name: Set version in manifest.json | |
shell: bash | |
run: | | |
for file in */*/manifest.json; do | |
jq ".version = \"${{ needs.build.outputs.git-hash }}\"" "${file}" > "${file}.tmp" | |
mv "${file}.tmp" "${file}" | |
done | |
- name: Copy artifacts | |
shell: bash | |
run: | | |
cp -R "artifacts/"*/* ./ | |
rm -r "artifacts/" | |
- name: Deploy 🚀 | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: Bump firmware version to ${{ needs.build.outputs.git-hash }} | |
committer_name: GitHub Actions | |
committer_email: [email protected] |