Skip to content

Commit 1640541

Browse files
ci: adopt arm64 changes from WDR as-is
1 parent b9aa8bb commit 1640541

File tree

7 files changed

+381
-142
lines changed

7 files changed

+381
-142
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Install LLVM
2+
3+
inputs:
4+
version:
5+
description: "LLVM version to install"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Install LLVM ${{ inputs.version }}
12+
shell: pwsh
13+
run: |
14+
if ((Get-WinGetPackage -Id LLVM -Source winget -MatchOption Equals).InstalledVersion -eq '${{ inputs.version }}') {
15+
Write-Host "LLVM ${{ inputs.version }} is already installed."
16+
} else {
17+
Write-Host "Installing LLVM ${{ inputs.version }}..."
18+
Install-WinGetPackage -Id LLVM.LLVM -Version ${{ inputs.version }} -Source winget -MatchOption Equals -Mode Silent -Force
19+
20+
# Check if WinGet installation succeeded
21+
$installSuccess = $?
22+
if (-not $installSuccess) {
23+
Write-Error "LLVM installation failed. Last exit code: $LASTEXITCODE and success status: $installSuccess"
24+
exit 1
25+
}
26+
}
27+
28+
clang --version
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Install WDK
2+
3+
inputs:
4+
version:
5+
description: "WDK version to install. Format: 10.0.XXXXX or 10.0.XXXXX.YYYY. If QFE (4th component) is omitted, the latest available QFE is selected."
6+
required: true
7+
source:
8+
description: "Source to install WDK from (nuget or winget)."
9+
required: true
10+
# required to set WDKBinRoot and WDKToolRoot based on the host architecture when using nuget
11+
host:
12+
description: "Host architecture (x64 or ARM64)."
13+
required: true
14+
# required to set WDKContentRoot based on the target architecture when using nuget
15+
target:
16+
description: "Target architecture (x64 or ARM64)."
17+
required: true
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Install WDK
23+
shell: pwsh
24+
run: |
25+
# Function to normalize architecture names
26+
function Normalize-Architecture($arch) {
27+
switch ($arch.ToLower()) {
28+
'amd64' { return 'x64' }
29+
'arm64' { return 'arm64' }
30+
default {
31+
Write-Error "Invalid architecture: $arch. Supported architectures are 'amd64' and 'arm64'."
32+
exit 1
33+
}
34+
}
35+
}
36+
37+
$hostArch = Normalize-Architecture '${{ inputs.host }}'
38+
$targetArch = Normalize-Architecture '${{ inputs.target }}'
39+
40+
$inputVersion = '${{ inputs.version }}'
41+
if ($inputVersion -notmatch '^10\.0\.\d{5}(\.\d{1,4})?$') {
42+
Write-Error "Invalid version format: $inputVersion"
43+
exit 1
44+
}
45+
$versionParts = $inputVersion.Split('.')
46+
$sdkVersion = $versionParts[0..2] -join '.'
47+
48+
$source = '${{ inputs.source }}'
49+
if ($source -ne 'nuget' -and $source -ne 'winget') {
50+
Write-Error "Invalid source: $source. Supported sources are 'nuget' and 'winget'."
51+
exit 1
52+
}
53+
54+
if ($source -eq 'nuget') {
55+
56+
if ($versionParts.Length -eq 3) {
57+
# No QFE specified, find the latest QFE for this base version
58+
Write-Host "No QFE specified, searching for latest QFE for version $inputVersion..."
59+
$baseVersion = $inputVersion
60+
try {
61+
$availableVersions = @()
62+
Write-Host "Trying NuGet API..."
63+
try {
64+
# Check available `x64` versions. `arm64` and `x64` kits are released together almost always
65+
$nugetApiUrl = "https://api.nuget.org/v3-flatcontainer/microsoft.windows.wdk.x64/index.json"
66+
$response = Invoke-RestMethod -Uri $nugetApiUrl -ErrorAction SilentlyContinue
67+
if ($response -and $response.versions) {
68+
$availableVersions = $response.versions | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' }
69+
Write-Host "Found $($availableVersions.Count) versions using NuGet API"
70+
}
71+
} catch {
72+
Write-Host "NuGet API query failed: $_"
73+
exit 1
74+
}
75+
76+
# Filter versions that match the base version and find the latest QFE
77+
$matchingVersions = $availableVersions | Where-Object { $_.StartsWith("$baseVersion.") }
78+
if ($matchingVersions.Count -eq 0) {
79+
Write-Warning "No QFE versions found for base version $baseVersion, trying without QFE..."
80+
$version = $inputVersion
81+
} else {
82+
# Sort versions and get the latest
83+
$version = $matchingVersions | Sort-Object { [System.Version]$_ } | Select-Object -Last 1
84+
Write-Host "Found latest QFE version: $version"
85+
}
86+
} catch {
87+
Write-Warning "Failed to query NuGet for latest QFE version: $_"
88+
exit 1
89+
}
90+
} else {
91+
$version = $inputVersion
92+
Write-Host "Using specified version: $version"
93+
}
94+
95+
$packages = "C:\packages"
96+
97+
Write-Host "Trying nuget install for version $version..."
98+
try {
99+
Write-Host "Installing Microsoft.Windows.SDK.CPP version $version..."
100+
nuget install Microsoft.Windows.SDK.CPP -Version $version -OutputDirectory $packages
101+
if ($LASTEXITCODE -ne 0) { throw "Microsoft.Windows.SDK.CPP" }
102+
103+
Write-Host "Installing Microsoft.Windows.WDK.x64 version $version..."
104+
nuget install Microsoft.Windows.WDK.x64 -Version $version -OutputDirectory $packages
105+
if ($LASTEXITCODE -ne 0) { throw "Microsoft.Windows.WDK.x64" }
106+
107+
Write-Host "Installing Microsoft.Windows.WDK.arm64 version $version..."
108+
nuget install Microsoft.Windows.WDK.arm64 -Version $version -OutputDirectory $packages
109+
if ($LASTEXITCODE -ne 0) { throw "Microsoft.Windows.WDK.arm64" }
110+
111+
Write-Host "Successfully installed all WDK packages for version $version"
112+
} catch {
113+
Write-Error "Failed to install $_ version $version"
114+
exit 1
115+
}
116+
if (-not (Test-Path $packages)) {
117+
Write-Error "$packages path could not be found. Please check the WDK version and source."
118+
exit 1
119+
}
120+
121+
Write-Host "Setting WDKContentRoot environment variable..."
122+
Write-Output "WDKContentRoot=$packages\Microsoft.Windows.WDK.$targetArch.$version\c\" >> $env:GITHUB_ENV
123+
124+
Write-Host "Setting Version_Number environment variable..."
125+
Write-Output "Version_Number=$sdkVersion.0" >> $env:GITHUB_ENV
126+
127+
Write-Host "Setting WDKBinRoot environment variable..."
128+
Write-Output "WDKBinRoot=$packages\Microsoft.Windows.WDK.$hostArch.$version\c\bin" >> $env:GITHUB_ENV
129+
130+
Write-Host "Setting WDKToolRoot environment variable..."
131+
Write-Output "WDKToolRoot=$packages\Microsoft.Windows.WDK.$hostArch.$version\c\tools" >> $env:GITHUB_ENV
132+
133+
Write-Host "Setting WindowsSdkBinPath environment variable..."
134+
Write-Output "WindowsSdkBinPath=$packages\Microsoft.Windows.SDK.CPP.$version\c\bin" >> $env:GITHUB_ENV
135+
} else {
136+
137+
Write-Host "Using Winget to install WDK and SDK version $inputVersion..."
138+
139+
$sdk = "Microsoft.WindowsSDK.$sdkVersion"
140+
$wdk = "Microsoft.WindowsWDK.$inputVersion"
141+
Write-Host "Installing $sdk..."
142+
Install-WinGetPackage -Id $sdk -Source winget -MatchOption Equals -Mode Silent -Force -Override '/q /features +'
143+
$installSuccess = $?
144+
if (-not $installSuccess) {
145+
Write-Error "$sdk installation failed. Last exit code: $LASTEXITCODE and success status: $installSuccess"
146+
exit 1
147+
}
148+
149+
Write-Host "Installing $wdk..."
150+
Install-WinGetPackage -Id $wdk -Source winget -MatchOption Equals -Mode Silent -Force
151+
$installSuccess = $?
152+
if (-not $installSuccess) {
153+
Write-Error "$wdk installation failed. Last exit code: $LASTEXITCODE and success status: $installSuccess"
154+
exit 1
155+
}
156+
157+
Write-Host "Setting Version_Number environment variable to $sdkVersion..."
158+
Write-Output "Version_Number=$sdkVersion.0" >> $env:GITHUB_ENV
159+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "Install Winget"
2+
description: "Install winget on windows runners since its not installed by default: https://github.com/actions/runner-images/issues/6472"
3+
inputs:
4+
GITHUB_TOKEN:
5+
description: "GitHub token to execute authenticated Github API requests (for higher rate limit)"
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Get URIs for Winget v1.11.400 assets
11+
shell: pwsh
12+
run: |
13+
$AuthenticatedHeaders = @{ "Authorization" = "Bearer ${{ inputs.GITHUB_TOKEN }}" }
14+
15+
# Detect runner architecture
16+
$Architecture = if ($env:RUNNER_ARCH -eq "ARM64") { "arm64" } else { "x64" }
17+
Write-Host "Runner architecture: $Architecture"
18+
19+
# winget-cli release v1.11.400
20+
# Define the winget-cli release tag to use
21+
$WingetReleaseTag = "v1.11.400"
22+
# Fetch release info by tag instead of magic number release ID
23+
$ReleaseInfo = Invoke-RestMethod -Headers $AuthenticatedHeaders "https://api.github.com/repos/microsoft/winget-cli/releases/tags/$WingetReleaseTag"
24+
$WingetDownloadUri = $ReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('.msixbundle') }
25+
$WingetLicenseDownloadUri = $ReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('License1.xml') }
26+
$WingetDependenciesZipDownloadUri = $ReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('DesktopAppInstaller_Dependencies.zip') }
27+
28+
# Print to logs
29+
Write-Host "WingetDownloadUri=$WingetDownloadUri"
30+
Write-Host "WingetLicenseDownloadUri=$WingetLicenseDownloadUri"
31+
Write-Host "WingetDependenciesZipDownloadUri=$WingetDependenciesZipDownloadUri"
32+
33+
# Save output for next step
34+
Write-Output "WingetDownloadUri=$WingetDownloadUri" >> $env:GITHUB_ENV
35+
Write-Output "WingetLicenseDownloadUri=$WingetLicenseDownloadUri" >> $env:GITHUB_ENV
36+
Write-Output "Architecture=$Architecture" >> $env:GITHUB_ENV
37+
Write-Output "WingetDependenciesZipDownloadUri=$WingetDependenciesZipDownloadUri" >> $env:GITHUB_ENV
38+
Write-Output "InstallWingetTempDir=$env:RUNNER_TEMP/install-winget" >> $env:GITHUB_ENV
39+
40+
- name: Download Winget Assets and Dependencies
41+
shell: pwsh
42+
run: |
43+
New-Item -Type Directory $env:InstallWingetTempDir
44+
45+
# Download winget and license (architecture-agnostic)
46+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:WingetDownloadUri -OutFile $env:InstallWingetTempDir/winget.msixbundle
47+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:WingetLicenseDownloadUri -OutFile $env:InstallWingetTempDir/license.xml
48+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:WingetDependenciesZipDownloadUri -OutFile $env:InstallWingetTempDir/DesktopAppInstaller_Dependencies.zip
49+
50+
Expand-Archive -Path "$env:InstallWingetTempDir/DesktopAppInstaller_Dependencies.zip" -DestinationPath $env:InstallWingetTempDir/ -Force
51+
52+
- name: Start Winget Installation for all Users
53+
shell: pwsh
54+
run: |
55+
# Use architecture-specific dependency paths
56+
[string[]]$DependencyPaths = (Get-ChildItem -Path "$env:InstallWingetTempDir/$env:Architecture" -Filter '*.appx' -File -Force).FullName
57+
58+
$MicrosoftUIXamlDep = $($DependencyPaths[0])
59+
$MicrosoftVCLibsDep = $($DependencyPaths[1])
60+
61+
Write-Host "Found Dependency $MicrosoftUIXamlDep"
62+
Write-Host "Found Dependency $MicrosoftVCLibsDep"
63+
64+
Add-AppxProvisionedPackage -Online -PackagePath $env:InstallWingetTempDir/winget.msixbundle -LicensePath $env:InstallWingetTempDir/license.xml -DependencyPackagePath "$MicrosoftUIXamlDep", "$MicrosoftVCLibsDep"
65+
66+
- name: Install Winget for Current User (for better install diagnostics)
67+
shell: powershell
68+
run: |
69+
Add-AppxPackage $env:InstallWingetTempDir/winget.msixbundle
70+
71+
- name: Wait for Completion of Winget Installation
72+
shell: pwsh
73+
run: |
74+
while ((Get-Command * | Select-String winget)?.ToString() -ne "winget.exe") {
75+
Start-Sleep -Seconds 1
76+
}
77+
Write-Output "Winget Version: $(winget --version)"
78+
79+
- name: Install winget Powershell Module
80+
shell: pwsh
81+
run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force

.github/actions/winget-install/action.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ env:
1515
jobs:
1616
build:
1717
name: Build
18-
runs-on: windows-latest
1918
strategy:
2019
fail-fast: false # Allow all matrix variants to complete even if some fail
2120
matrix:
21+
runner:
22+
- name: windows-latest
23+
arch: amd64
24+
- name: windows-11-arm
25+
arch: arm64
26+
2227
wdk:
23-
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
28+
- version: 10.0.22621 # NI WDK
29+
source: winget
30+
- version: 10.0.26100 # GE WDK
31+
source: nuget
2432

2533
llvm:
2634
- 17.0.6
@@ -40,34 +48,29 @@ jobs:
4048
- name: aarch64-pc-windows-msvc
4149
arch: arm64
4250

51+
runs-on: ${{ matrix.runner.name }}
52+
4353
steps:
4454
- name: Checkout Repository
4555
uses: actions/checkout@v4
4656

4757
- name: Install Winget
48-
uses: ./.github/actions/winget-install
58+
uses: ./.github/actions/install-winget
4959
with:
5060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5161

5262
- name: Install LLVM ${{ matrix.llvm }}
53-
run: |
54-
if ((Get-WinGetPackage -Id LLVM -Source winget -MatchOption Equals).InstalledVersion -eq '${{ matrix.llvm }}') {
55-
Write-Host "LLVM ${{ matrix.llvm }} is already installed."
56-
} else {
57-
Write-Host "Installing LLVM ${{ matrix.llvm }}..."
58-
Install-WinGetPackage -Id LLVM.LLVM -Version ${{ matrix.llvm }} -Source winget -MatchOption Equals -Mode Silent -Force
59-
}
60-
clang --version
61-
62-
- name: Install WDK (${{ matrix.wdk }})
63-
run: |
64-
if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') {
65-
Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..."
66-
Update-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
67-
} else {
68-
Write-Host "Installing ${{ matrix.wdk }}..."
69-
Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force
70-
}
63+
uses: ./.github/actions/install-llvm
64+
with:
65+
version: ${{ matrix.llvm }}
66+
67+
- name: Install WDK (${{ matrix.wdk.version }})
68+
uses: ./.github/actions/install-wdk
69+
with:
70+
version: ${{ matrix.wdk.version }}
71+
source: ${{ matrix.wdk.source }}
72+
host: ${{ matrix.runner.arch }}
73+
target: ${{ matrix.target_triple.arch }}
7174

7275
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
7376
uses: dtolnay/rust-toolchain@master

0 commit comments

Comments
 (0)