Skip to content

Commit 751af64

Browse files
GPG changed default install location on 12/31/2025 for Windows (#26917)
### Description Update search for GPG to check for both Program Files and Program Files (x86) ### Motivation and Context --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 517e06c commit 751af64

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

tools/ci_build/github/azure-pipelines/templates/jar-maven-signing-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ steps:
2525
inputs:
2626
scriptPath: "$(Build.SourcesDirectory)/tools/ci_build/github/windows/sign_java_artifacts.py"
2727
arguments: "${{ parameters.JarFileDirectory }}"
28-
workingDirectory: "$(Build.SourcesDirectory)"
28+
workingDirectory: "$(Build.SourcesDirectory)"

tools/ci_build/github/azure-pipelines/templates/jar-packaging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ steps:
5858
inputs:
5959
scriptPath: '$(Build.SourcesDirectory)/tools/ci_build/github/windows/sign_java_artifacts.py'
6060
arguments: '$(Build.BinariesDirectory)\java-artifact\onnxruntime-java-win-x64'
61-
workingDirectory: '$(Build.SourcesDirectory)'
61+
workingDirectory: '$(Build.SourcesDirectory)'

tools/ci_build/github/windows/sign_java_artifacts.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,34 @@
99
from pathlib import Path
1010

1111

12+
def clean_gpg_trustdb() -> None:
13+
if platform.system() == "Windows":
14+
# Clean up GPG trust database if it exists
15+
appdata = os.environ.get("APPDATA")
16+
if appdata:
17+
trustdb_path = Path(appdata) / "gnupg" / "trustdb.gpg"
18+
if trustdb_path.exists():
19+
try:
20+
trustdb_path.unlink()
21+
except OSError as e:
22+
print(f"Warning: failed to delete GPG trust database at {trustdb_path}: {e}")
23+
24+
1225
def get_gpg_path() -> Path:
1326
"""Finds the path to the GPG executable."""
1427
if platform.system() == "Windows":
28+
# Check both Program Files (x86) and Program Files, gpg distribution
29+
# changed on 12/31/2025
1530
program_files_x86 = os.environ.get("ProgramFiles(x86)") # noqa: SIM112
16-
if not program_files_x86:
17-
raise OSError("ProgramFiles(x86) environment variable not found.")
18-
return Path(program_files_x86) / "gnupg/bin/gpg.exe"
31+
program_files = os.environ.get("ProgramFiles") # noqa: SIM112
32+
33+
for base_path in [program_files_x86, program_files]:
34+
if base_path:
35+
gpg_path = Path(base_path) / "gnupg/bin/gpg.exe"
36+
if gpg_path.is_file():
37+
return gpg_path
38+
39+
raise FileNotFoundError("GPG executable not found in Program Files or Program Files (x86).")
1940

2041
gpg_path_str = shutil.which("gpg")
2142
if gpg_path_str is None:
@@ -103,8 +124,15 @@ def main() -> None:
103124
private_key_file.write_text(gpg_private_key, encoding="utf-8")
104125
passphrase_file.write_text(gpg_passphrase, encoding="utf-8")
105126

127+
# Clear GPG trustdb to avoid issues with cached trust settings
128+
clean_gpg_trustdb()
129+
130+
# Check GPG trust database to generate a fresh one
131+
print("Checking trust db")
132+
run_command([str(gpg_exe_path), "--check-trustdb"])
133+
106134
print("Importing GnuPG private key.")
107-
run_command([str(gpg_exe_path), "--batch", "--import", str(private_key_file)])
135+
run_command([str(gpg_exe_path), "--batch", "--yes", "--import", str(private_key_file)])
108136
print("Successfully imported GnuPG private key.")
109137

110138
print(f"\nProcessing {len(files_to_process)} files in '{jar_file_directory}'.")

0 commit comments

Comments
 (0)