Skip to content

Commit db88fb9

Browse files
authored
fix: dynamically detect Windows SDK tools for GitHub Actions compatibility (#686)
1 parent a08eae5 commit db88fb9

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

.github/actions/build-binaries/windows/action.yaml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,58 @@ runs:
2626
using: "composite"
2727
steps:
2828
- name: Configure build environment
29-
shell: bash
29+
shell: pwsh
3030
run: |
31-
echo 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64' >> $GITHUB_PATH
32-
echo 'BINARY_BUILD_DIR=dist\algokit' >> $GITHUB_ENV
33-
echo 'WINGET_INSTALLER=${{ inputs.artifacts_dir }}\${{ inputs.package_name }}-winget.msix' >> $GITHUB_ENV
31+
# Find Windows SDK tools dynamically (works on both Windows 2022 and 2025)
32+
$sdkPath = "C:\Program Files (x86)\Windows Kits\10\bin"
33+
34+
# First, try to find makepri and makeappx in PATH
35+
$makepriCmd = Get-Command makepri -ErrorAction SilentlyContinue
36+
$makeappxCmd = Get-Command makeappx -ErrorAction SilentlyContinue
37+
38+
if (-not $makepriCmd -or -not $makeappxCmd) {
39+
Write-Host "SDK tools not in PATH, searching for Windows SDK..."
40+
41+
if (Test-Path $sdkPath) {
42+
# Find the latest SDK version
43+
$latestVersion = Get-ChildItem $sdkPath -Directory |
44+
Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } |
45+
Sort-Object { [Version]$_.Name } -Descending |
46+
Select-Object -First 1
47+
48+
if ($latestVersion) {
49+
$sdkBinPath = Join-Path $latestVersion.FullName "x64"
50+
Write-Host "Adding Windows SDK to PATH: $sdkBinPath"
51+
echo "$sdkBinPath" >> $env:GITHUB_PATH
52+
53+
# Verify tools exist
54+
$makepriPath = Join-Path $sdkBinPath "makepri.exe"
55+
$makeappxPath = Join-Path $sdkBinPath "makeappx.exe"
56+
57+
if (-not (Test-Path $makepriPath)) {
58+
throw "makepri.exe not found at $makepriPath"
59+
}
60+
if (-not (Test-Path $makeappxPath)) {
61+
throw "makeappx.exe not found at $makeappxPath"
62+
}
63+
64+
Write-Host "✓ Found makepri.exe at: $makepriPath"
65+
Write-Host "✓ Found makeappx.exe at: $makeappxPath"
66+
} else {
67+
throw "No Windows SDK versions found in $sdkPath"
68+
}
69+
} else {
70+
throw "Windows SDK not found at $sdkPath"
71+
}
72+
} else {
73+
Write-Host "✓ SDK tools already in PATH"
74+
Write-Host " makepri: $($makepriCmd.Source)"
75+
Write-Host " makeappx: $($makeappxCmd.Source)"
76+
}
77+
78+
# Set environment variables
79+
echo 'BINARY_BUILD_DIR=dist\algokit' >> $env:GITHUB_ENV
80+
echo 'WINGET_INSTALLER=${{ inputs.artifacts_dir }}\${{ inputs.package_name }}-winget.msix' >> $env:GITHUB_ENV
3481
3582
- name: Build binary
3683
shell: bash

0 commit comments

Comments
 (0)