Skip to content

Commit 08dc3a1

Browse files
committed
fix build/release
1 parent 94f0db3 commit 08dc3a1

4 files changed

Lines changed: 421 additions & 55 deletions

File tree

.github/workflows/light-firmware-build.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ on:
2323
- "AGENTS.md"
2424
workflow_dispatch:
2525

26+
permissions:
27+
contents: read
28+
2629
jobs:
2730
build-light-core:
2831
runs-on: ubuntu-latest
@@ -62,7 +65,7 @@ jobs:
6265
path: |
6366
esp-matter
6467
.git/modules/esp-matter
65-
key: ${{ runner.os }}-esp-matter-submodules-v1-${{ hashFiles('.gitmodules') }}-${{ steps.esp-matter-rev.outputs.sha }}
68+
key: ${{ runner.os }}-esp-matter-submodules-v2-${{ steps.esp-matter-rev.outputs.sha }}
6669

6770
- name: Sync submodules
6871
shell: bash
@@ -96,11 +99,7 @@ jobs:
9699
uses: actions/cache/restore@v4
97100
with:
98101
path: esp-matter/connectedhomeip/connectedhomeip/.environment
99-
key: ${{ runner.os }}-matter-bootstrap-v2-${{
100-
hashFiles('esp-matter/connectedhomeip/connectedhomeip/scripts/setup/**/*.txt',
101-
'esp-matter/connectedhomeip/connectedhomeip/scripts/setup/**/*.json',
102-
'esp-matter/connectedhomeip/connectedhomeip/BUILD.gn',
103-
'esp-matter/install.sh') }}
102+
key: ${{ runner.os }}-matter-bootstrap-v3-${{ steps.esp-matter-rev.outputs.sha }}
104103

105104
- name: Bootstrap Matter environment
106105
shell: bash
@@ -127,8 +126,7 @@ jobs:
127126
uses: actions/cache/restore@v4
128127
with:
129128
path: /root/.cache/pip
130-
key: ${{ runner.os }}-esp-matter-pip-v1-${{
131-
hashFiles('esp-matter/requirements.txt') }}
129+
key: ${{ runner.os }}-esp-matter-pip-v2-${{ steps.esp-matter-rev.outputs.sha }}
132130

133131
- name: Install repo-local Python deps
134132
shell: bash
@@ -148,11 +146,9 @@ jobs:
148146
uses: actions/cache/restore@v4
149147
with:
150148
path: .ccache
151-
key: ${{ runner.os }}-light-c6-thread-ccache-v1-${{ github.ref_name }}-${{
152-
github.sha }}
149+
key: ${{ runner.os }}-light-c6-thread-ccache-v2-${{ steps.esp-matter-rev.outputs.sha }}
153150
restore-keys: |
154-
${{ runner.os }}-light-c6-thread-ccache-v1-${{ github.ref_name }}-
155-
${{ runner.os }}-light-c6-thread-ccache-v1-
151+
${{ runner.os }}-light-c6-thread-ccache-v2-
156152
157153
- name: Configure base light firmware
158154
shell: bash
@@ -229,6 +225,8 @@ jobs:
229225
needs:
230226
- package-light-core
231227
if: startsWith(github.ref, 'refs/tags/v')
228+
permissions:
229+
contents: write
232230

233231
steps:
234232
- name: Download packaged artifact

tools/generate_label_html.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
import argparse
7+
import hashlib
78
import io
89
import json
910
import pathlib
@@ -20,6 +21,9 @@
2021
from .tool_paths import DEFAULT_DEVICES_CSV_PATH, DEFAULT_LABEL_HTML_PATH
2122

2223
LABEL_BORDER_WIDTH_MM = 0.35
24+
DEFAULT_LABEL_WIDTH_MM = 10.0
25+
DEFAULT_LABEL_HEIGHT_MM = 15.0
26+
LABEL_BUILD_FINGERPRINT_PREFIX = "label-build-fingerprint:"
2327

2428

2529
HTML_TEMPLATE = """<!doctype html>
@@ -28,6 +32,7 @@
2832
<meta charset="utf-8">
2933
<meta name="viewport" content="width=device-width, initial-scale=1">
3034
<title>Matter Labels</title>
35+
<!-- {build_fingerprint_comment} -->
3136
<style>
3237
:root {{
3338
--page-pad: {page_pad_mm}mm;
@@ -553,13 +558,13 @@ def parse_args() -> argparse.Namespace:
553558
parser.add_argument(
554559
"--label-width-mm",
555560
type=float,
556-
default=10.0,
561+
default=DEFAULT_LABEL_WIDTH_MM,
557562
help="Printed label width in millimeters. Max 10 mm.",
558563
)
559564
parser.add_argument(
560565
"--label-height-mm",
561566
type=float,
562-
default=15.0,
567+
default=DEFAULT_LABEL_HEIGHT_MM,
563568
help="Printed label height in millimeters. Max 15 mm.",
564569
)
565570
return parser.parse_args()
@@ -579,9 +584,27 @@ class LayoutMetrics:
579584
def build_qr_svg_markup(payload: str) -> str:
580585
segno_module = verify_segno_dependency(sys.executable)
581586
qr = segno_module.make(payload)
582-
output = io.StringIO()
587+
output = io.BytesIO()
583588
qr.save(output, kind="svg", scale=1, border=0, xmldecl=False)
584-
return output.getvalue()
589+
return output.getvalue().decode("utf-8")
590+
591+
592+
def build_label_html_fingerprint(
593+
label_rows: list[dict[str, str]],
594+
*,
595+
label_width_mm: float,
596+
label_height_mm: float,
597+
) -> str:
598+
payload = json.dumps(
599+
{
600+
"label_rows": label_rows,
601+
"label_width_mm": label_width_mm,
602+
"label_height_mm": label_height_mm,
603+
},
604+
sort_keys=True,
605+
separators=(",", ":"),
606+
)
607+
return hashlib.sha256(payload.encode("utf-8")).hexdigest()
585608

586609

587610
def compute_layout_metrics(label_width_mm: float, label_height_mm: float) -> LayoutMetrics:
@@ -622,12 +645,18 @@ def main() -> int:
622645
rows = load_device_rows(devices_csv)
623646
selected_rows = filter_rows_by_serial(rows, args.serial)
624647
label_rows = build_label_rows(selected_rows, include_passcode=False)
648+
build_fingerprint = build_label_html_fingerprint(
649+
label_rows,
650+
label_width_mm=args.label_width_mm,
651+
label_height_mm=args.label_height_mm,
652+
)
625653
for label_row in label_rows:
626654
label_row["qr_svg"] = build_qr_svg_markup(label_row["qrcode"])
627655
layout = compute_layout_metrics(args.label_width_mm, args.label_height_mm)
628656
json_payload = json.dumps(label_rows).replace("</", "<\\/")
629657

630658
html_output = HTML_TEMPLATE.format(
659+
build_fingerprint_comment=f"{LABEL_BUILD_FINGERPRINT_PREFIX}{build_fingerprint}",
631660
json_payload=json_payload,
632661
label_width_mm=args.label_width_mm,
633662
label_height_mm=args.label_height_mm,

0 commit comments

Comments
 (0)