Skip to content

Commit 1222932

Browse files
lebaucepull[bot]
authored andcommitted
Use version from zap.json to download zap (#25791)
1 parent 8e078f8 commit 1222932

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

scripts/tools/zap/zap_download.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
import enum
1818
import io
19+
import json
1920
import logging
2021
import os
21-
import re
2222
import shlex
2323
import shutil
2424
import subprocess
@@ -141,19 +141,19 @@ def _GetZapVersionToUse(project_root):
141141
# This heuristic may be bad at times, however then you can also override the
142142
# version in command line parameters
143143

144-
match_re = re.compile(r'.*ENV\s+ZAP_VERSION=([^# ]*)')
145-
146-
docker_path = os.path.join(project_root, "integrations/docker/images/chip-build/Dockerfile")
147-
148-
with open(docker_path, 'rt') as f:
149-
for l in f.readlines():
150-
l = l.strip()
151-
m = match_re.match(l)
152-
if not m:
153-
continue
154-
return m.group(1)
155-
156-
raise Exception(f"Failed to determine version from {docker_path}")
144+
zap_version = ""
145+
zap_path = os.path.join(project_root, "scripts/setup/zap.json")
146+
zap_json = json.load(open(zap_path))
147+
for package in zap_json.get("packages", []):
148+
for tag in package.get("tags", []):
149+
if tag.startswith("version:2@"):
150+
zap_version = tag.removeprefix("version:2@")
151+
suffix_index = zap_version.rfind(".")
152+
if suffix_index != -1:
153+
zap_version = zap_version[:suffix_index]
154+
return zap_version
155+
156+
raise Exception(f"Failed to determine version from {zap_path}")
157157

158158

159159
@click.command()

0 commit comments

Comments
 (0)