Skip to content
Merged
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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,10 @@ jobs:

- name: Validate json file matches ${{ matrix.manifest }} manifest-template.json
run: |
jq -n --arg md5 "$(md5sum test-esp32.ota.bin | head -c 32)" -f tests/${{ matrix.manifest }}-manifest-template.json > /tmp/manifest.json
jq -n \
--arg ota_md5 "$(md5sum test-esp32.ota.bin | head -c 32)" \
--arg ota_sha256 "$(sha256sum test-esp32.ota.bin | head -c 64)" \
--arg factory_md5 "$(md5sum test-esp32.factory.bin | head -c 32)" \
--arg factory_sha256 "$(sha256sum test-esp32.factory.bin | head -c 64)" \
-f tests/${{ matrix.manifest }}-manifest-template.json > /tmp/manifest.json
diff <(jq --sort-keys . /tmp/manifest.json) <(jq --sort-keys . manifest.json)
9 changes: 9 additions & 0 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,15 @@ def generate_manifest_part(

with open(ota_bin, "rb") as f:
ota_md5 = hashlib.md5(f.read()).hexdigest()
f.seek(0)
ota_sha256 = hashlib.sha256(f.read()).hexdigest()

manifest = {
"chipFamily": chip_family,
"ota": {
"path": ota_bin.name,
"md5": ota_md5,
"sha256": ota_sha256,
},
}

Expand All @@ -242,10 +245,16 @@ def generate_manifest_part(
manifest["ota"]["release_url"] = release_url

if has_factory_part:
with open(factory_bin, "rb") as f:
factory_md5 = hashlib.md5(f.read()).hexdigest()
f.seek(0)
factory_sha256 = hashlib.sha256(f.read()).hexdigest()
manifest["parts"] = [
{
"path": str(factory_bin.name),
"offset": 0x00,
"md5": factory_md5,
"sha256": factory_sha256,
}
]

Expand Down
7 changes: 5 additions & 2 deletions tests/complete-manifest-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
"chipFamily": "ESP32",
"ota": {
"path": "test-esp32.ota.bin",
"md5": "\($md5)",
"md5": "\($ota_md5)",
"sha256": "\($ota_sha256)",
"summary": "Test \"release\" summary\n* Multiple lines",
"release_url": "https://github.com/esphome/build-action"
},
"parts": [
{
"path": "test-esp32.factory.bin",
"offset": 0
"offset": 0,
"md5": "\($factory_md5)",
"sha256": "\($factory_sha256)"
}
]
}
Expand Down
7 changes: 5 additions & 2 deletions tests/partial-manifest-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"chipFamily": "ESP32",
"ota": {
"path": "test-esp32.ota.bin",
"md5": "\($md5)",
"md5": "\($ota_md5)",
"sha256": "\($ota_sha256)",
"summary": "Test \"release\" summary\n* Multiple lines",
"release_url": "https://github.com/esphome/build-action"
},
"parts": [
{
"path": "test-esp32.factory.bin",
"offset": 0
"offset": 0,
"md5": "\($factory_md5)",
"sha256": "\($factory_sha256)"
}
]
}