From 7987d01a6ee1b51c50ceb92a1679c536d79af7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Garcia?= Date: Fri, 10 Oct 2025 07:58:55 +0000 Subject: [PATCH] chore: Fix import of GPG keys when two keys are provided * chore: Fix import of GPG keys when two keys are provided We were only retrieving the first output of gpg.list keys because previously we were only running import_gpg_keys once. Now that we run it twice we need to ensure that the key we select from the list matches the one we've imported. --- release_pkgs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/release_pkgs.py b/release_pkgs.py index 0045eb57..075a826a 100644 --- a/release_pkgs.py +++ b/release_pkgs.py @@ -189,11 +189,22 @@ class PkgCreator: def import_gpg_keys(self, private_key, public_key): gpg = gnupg.GPG() private_key = base64.b64decode(private_key) - gpg.import_keys(private_key) + import_result = gpg.import_keys(private_key) + if not import_result.fingerprints: + raise Exception("Failed to import private key") + public_key = base64.b64decode(public_key) gpg.import_keys(public_key) + + imported_fingerprint = import_result.fingerprints[0] data = gpg.list_keys(secret=True) - return (data[0]["fingerprint"], data[0]["uids"][0]) + + # Find the specific key we just imported by comparing fingerprints + for key in data: + if key["fingerprint"] == imported_fingerprint: + return (key["fingerprint"], key["uids"][0]) + + raise Exception(f"Could not find imported key with fingerprint {imported_fingerprint}") def import_multiple_gpg_keys(self, primary_private_key, primary_public_key, secondary_private_key=None, secondary_public_key=None): """