Files
Virtual-Display-Driver/.github/workflows/ci-validation.yml
T

266 lines
11 KiB
YAML

---
name: Build Virtual Display Driver
on:
pull_request:
push:
branches: [ main, master ]
tags: [ 'v*' ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE*'
workflow_dispatch:
inputs:
sign:
description: Submit the built Release packages to SignPath
required: false
default: false
type: boolean
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
# A replacement validation build may cancel an older validation build, but a
# submitted signing request must be allowed to complete and download its result.
cancel-in-progress: ${{ !((github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.sign)) }}
env:
BUILD_CONFIGURATION: Release
VDD_SOLUTION: Virtual Display Driver (HDR)/MttVDD.sln
# Signing is deliberate: release tags sign automatically, and a manual run
# must explicitly opt in. Pull requests and ordinary branch pushes never
# receive the SignPath token.
SIGNPATH_SIGNING_RUN: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.sign) }}
permissions:
actions: read
contents: read
jobs:
build:
# The WDK driver build is validated against VS 2022; windows-latest is moving to VS 2026.
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
platform: [x64, ARM64]
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
submodules: true
- name: Setup MSBuild
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3.0.0
- name: Install Windows Driver Kit (IddCx headers)
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
choco install windowsdriverkit11 -y --no-progress
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Detect Windows SDK (windows.h)
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$kitsRoot = $null
try {
$kitsRoot = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction Stop).KitsRoot10
} catch {
$kitsRoot = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\"
}
if (-not $kitsRoot -or -not (Test-Path $kitsRoot)) {
throw "Windows Kits root not found: $kitsRoot"
}
$includeRoot = Join-Path $kitsRoot "Include"
if (-not (Test-Path $includeRoot)) {
throw "Windows Kits Include directory not found: $includeRoot"
}
$best =
Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } |
Where-Object { Test-Path (Join-Path $_.FullName "um\Windows.h") } |
Sort-Object -Property Name -Descending |
Select-Object -First 1
if (-not $best) {
throw "Could not find an SDK version directory containing um\\Windows.h under: $includeRoot"
}
$sdkVersion = $best.Name
Write-Output "Using WindowsSdkDir: $kitsRoot"
Write-Output "Using WindowsTargetPlatformVersion: $sdkVersion"
"WINDOWS_SDK_DIR=$kitsRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"WINDOWS_TARGET_PLATFORM_VERSION=$sdkVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build VDD (${{ matrix.platform }})
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$sln = "${{ env.VDD_SOLUTION }}"
if (-not (Test-Path $sln)) { throw "VDD solution file not found at: $sln" }
# Pick an available UMDF WDF header version on the runner.
# Kits can be laid out either versioned:
# Include\<sdk>\wdf\umdf\2.xx
# or unversioned:
# Include\wdf\umdf\2.xx
$umdfRoots = @(
(Join-Path $env:WINDOWS_SDK_DIR ("Include\" + $env:WINDOWS_TARGET_PLATFORM_VERSION + "\wdf\umdf")),
(Join-Path $env:WINDOWS_SDK_DIR "Include\wdf\umdf")
) | Where-Object { Test-Path $_ }
if (-not $umdfRoots -or $umdfRoots.Count -eq 0) {
throw "UMDF WDF include root not found under $env:WINDOWS_SDK_DIR (tried versioned + unversioned layouts)"
}
$umdfBest =
$umdfRoots |
ForEach-Object { Get-ChildItem -Path $_ -Directory -ErrorAction SilentlyContinue } |
Where-Object { $_.Name -match '^\d+\.\d+$' } |
Sort-Object -Property Name -Descending |
Select-Object -First 1
if (-not $umdfBest) { throw "No UMDF version directories found under: $($umdfRoots -join ', ')" }
$umdfMinor = ($umdfBest.Name -split '\.')[1]
Write-Output "Using UMDF version: $($umdfBest.Name) (minor=$umdfMinor) from $($umdfBest.FullName)"
msbuild $sln `
/m `
/t:Build `
/p:Configuration="${{ env.BUILD_CONFIGURATION }}" `
/p:Platform="${{ matrix.platform }}" `
/p:WindowsSdkDir="$env:WINDOWS_SDK_DIR" `
/p:WindowsTargetPlatformVersion="$env:WINDOWS_TARGET_PLATFORM_VERSION" `
/p:UMDF_VERSION_MINOR="$umdfMinor" `
/p:EnableInfVerif=false `
/p:RunApiValidator=false `
/verbosity:minimal
- name: Collect outputs
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$outDir = "Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ env.BUILD_CONFIGURATION }}\MttVDD"
if (-not (Test-Path $outDir)) { throw "Build output directory not found: $outDir" }
$dest = "artifacts\VDD\${{ matrix.platform }}"
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Copy-Item "$outDir\*" -Destination $dest -Recurse -Force
# This is the complete installable UMDF package. SignPath receives the
# GitHub Actions ZIP containing these exact files, with no installer or
# unrelated driver payload mixed in.
$requiredFiles = @("MttVDD.dll", "MttVDD.inf", "MttVDD.cat", "vdd_settings.xml")
foreach ($file in $requiredFiles) {
if (-not (Test-Path (Join-Path $dest $file))) {
throw "Required driver package file not found: $file"
}
}
- name: Upload unsigned driver package
id: upload_unsigned_driver_package
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: VDD-${{ matrix.platform }}-${{ env.BUILD_CONFIGURATION }}
path: artifacts/VDD/${{ matrix.platform }}/
if-no-files-found: error
- name: Check SignPath configuration
if: env.SIGNPATH_SIGNING_RUN == 'true'
shell: pwsh
env:
SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
SIGNPATH_ORG_ID: ${{ vars.SIGNPATH_ORG_ID }}
SIGNPATH_PROJECT_SLUG: ${{ vars.SIGNPATH_PROJECT_SLUG }}
SIGNPATH_POLICY_SLUG: ${{ vars.SIGNPATH_POLICY_SLUG }}
run: |
$ErrorActionPreference = "Stop"
$required = @("SIGNPATH_API_TOKEN", "SIGNPATH_ORG_ID", "SIGNPATH_PROJECT_SLUG", "SIGNPATH_POLICY_SLUG")
$missing = @($required | Where-Object { [string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($_)) })
if ($missing.Count -gt 0) {
throw "Missing SignPath configuration: $($missing -join ', ')"
}
# The SignPath project's default artifact configuration must accept the
# GitHub artifact ZIP and preserve MttVDD.dll, MttVDD.inf, MttVDD.cat,
# and vdd_settings.xml. It should Authenticode-sign the DLL and catalog,
# while the INF and XML remain package payload.
- name: Submit VDD package to SignPath
id: submit_signing
if: env.SIGNPATH_SIGNING_RUN == 'true'
uses: signpath/github-action-submit-signing-request@f6d04783b4569d051e0c80105fe66e82819d0092 # v3.0.0
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ vars.SIGNPATH_ORG_ID }}
project-slug: ${{ vars.SIGNPATH_PROJECT_SLUG }}
signing-policy-slug: ${{ vars.SIGNPATH_POLICY_SLUG }}
github-artifact-id: ${{ steps.upload_unsigned_driver_package.outputs.artifact-id }}
github-token: ${{ github.token }}
wait-for-completion: true
wait-for-completion-timeout-in-seconds: 1800
output-artifact-directory: signed-artifacts/VDD/${{ matrix.platform }}/
- name: Verify signed driver package
if: env.SIGNPATH_SIGNING_RUN == 'true'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$signedRoot = "signed-artifacts\VDD\${{ matrix.platform }}"
if (-not (Test-Path $signedRoot)) { throw "SignPath did not create $signedRoot" }
$driver = @(Get-ChildItem -Path $signedRoot -Recurse -File -Filter "MttVDD.dll")
$catalog = @(Get-ChildItem -Path $signedRoot -Recurse -File -Filter "MttVDD.cat")
$inf = @(Get-ChildItem -Path $signedRoot -Recurse -File -Filter "MttVDD.inf")
$settings = @(Get-ChildItem -Path $signedRoot -Recurse -File -Filter "vdd_settings.xml")
foreach ($entry in @(
@{ Name = "MttVDD.dll"; Files = $driver },
@{ Name = "MttVDD.cat"; Files = $catalog },
@{ Name = "MttVDD.inf"; Files = $inf },
@{ Name = "vdd_settings.xml"; Files = $settings }
)) {
if ($entry.Files.Count -ne 1) {
throw "Expected exactly one signed package file named $($entry.Name), found $($entry.Files.Count)"
}
}
$signtool = Get-ChildItem -Path "${env:ProgramFiles(x86)}\Windows Kits\10\bin" -Recurse -File -Filter "signtool.exe" |
Where-Object { $_.FullName -match "\\x64\\signtool.exe$" } |
Sort-Object FullName -Descending |
Select-Object -First 1
if (-not $signtool) { throw "signtool.exe was not found in the installed Windows SDK" }
& $signtool.FullName verify /pa /v $driver[0].FullName
if ($LASTEXITCODE -ne 0) { throw "Authenticode verification failed for $($driver[0].FullName)" }
& $signtool.FullName verify /pa /v $catalog[0].FullName
if ($LASTEXITCODE -ne 0) { throw "Authenticode verification failed for $($catalog[0].FullName)" }
- name: Upload signed driver package
if: env.SIGNPATH_SIGNING_RUN == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: VDD-${{ matrix.platform }}-${{ env.BUILD_CONFIGURATION }}-signed
path: signed-artifacts/VDD/${{ matrix.platform }}/
if-no-files-found: error
retention-days: 90
- name: Add signing summary
if: env.SIGNPATH_SIGNING_RUN == 'true'
shell: pwsh
env:
SIGNING_REQUEST_URL: ${{ steps.submit_signing.outputs.signing-request-web-url }}
run: |
"## SignPath signing (${{ matrix.platform }})" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
"- Signed package: `VDD-${{ matrix.platform }}-${{ env.BUILD_CONFIGURATION }}-signed`" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
"- Signing request: $env:SIGNING_REQUEST_URL" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append