From 78f00d7d83ba89ab5afa8820f47f98aef85b83f0 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Fri, 8 Nov 2024 21:36:02 +0100 Subject: [PATCH] fix(fw): handle signed tags in releases-json.py --- scripts/releases-json.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/releases-json.py b/scripts/releases-json.py index a8654d4..50b13bb 100644 --- a/scripts/releases-json.py +++ b/scripts/releases-json.py @@ -145,18 +145,29 @@ def parse_changelog( def find_revision(version: str) -> str: - FIRMWARE_TAG_QUERY = ( + FIRMWARE_REF_TAG_QUERY = ( "https://api.github.com/repos/trezor/trezor-firmware/git/refs/tags/{tag}" ) + FIRMWARE_SIGNED_TAG_QUERY = ( + "https://api.github.com/repos/trezor/trezor-firmware/git/tags/{sha}" + ) if version.startswith("2"): tag = f"core/v{version}" else: tag = f"trezor-suite/v{version}" - r = requests.get(FIRMWARE_TAG_QUERY.format(tag=tag)) + r = requests.get(FIRMWARE_REF_TAG_QUERY.format(tag=tag)) r.raise_for_status() data = r.json() + + # signed tags have one more level of indirection + if data["object"]["type"] == "tag": + r = requests.get(FIRMWARE_SIGNED_TAG_QUERY.format(sha=data["object"]["sha"])) + r.raise_for_status() + data = r.json() + + assert data["object"]["type"] == "commit" return data["object"]["sha"]