--- name: Build Virtual Display Driver on: pull_request: push: branches: [ main, master ] paths-ignore: - '**.md' - 'docs/**' - 'LICENSE*' workflow_dispatch: inputs: control_ref: description: Virtual Driver Control commit SHA to package instead of the display driver type: string default: '' platform: description: Driver architecture to build type: choice options: [both, x64, ARM64] default: both release_signing: description: Request SignPath release signing for the selected builds type: boolean default: false concurrency: group: "${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && inputs.release_signing && 'signing' || 'validation' }}" cancel-in-progress: ${{ !(github.event_name == 'workflow_dispatch' && inputs.release_signing) }} env: BUILD_CONFIGURATION: Release VDD_SOLUTION: Virtual Display Driver (HDR)/MttVDD.sln UMDF_VERSION: '2.25' SIGNPATH_RELEASE_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.release_signing }} permissions: actions: read contents: read jobs: build: if: inputs.control_ref == '' # 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: ${{ fromJSON(inputs.platform == 'x64' && '["x64"]' || inputs.platform == 'ARM64' && '["ARM64"]' || '["x64","ARM64"]') }} steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: submodules: true persist-credentials: false - 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 matching Windows SDK and WDK headers 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")) -and (Test-Path (Join-Path $_.FullName "um\iddcx\1.10\IddCx.h")) } | Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1 if (-not $best) { throw "Could not find matching Windows SDK and IddCx headers 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" } # Use a released UMDF version that the target OS can load. # Kits can be laid out either versioned: # Include\\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)" } $umdf = $umdfRoots | ForEach-Object { Get-ChildItem -Path $_ -Directory -Filter $env:UMDF_VERSION -ErrorAction SilentlyContinue } | Select-Object -First 1 if (-not $umdf) { throw "UMDF $env:UMDF_VERSION headers are absent under $($umdfRoots -join ', ')" } $umdfMinor = ($env:UMDF_VERSION -split '\.')[1] Write-Output "Using UMDF $env:UMDF_VERSION headers from $($umdf.FullName)" $buildNumber = [int]$env:GITHUB_RUN_NUMBER if ($buildNumber -gt 65535) { throw "Driver version component exceeds 65535: $buildNumber" } $now = [DateTime]::UtcNow $driverVersion = "{0}.{1}.{2}.{3}" -f ($now.Year % 100), $now.Month, $now.Day, $buildNumber $driverDate = $now.ToString("MM/dd/yyyy", [Globalization.CultureInfo]::InvariantCulture) "VDD_DRIVER_VER=$driverDate,$driverVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append 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:VddDriverVersion="$driverVersion" ` /p:VddDriverDate="$driverDate" ` /p:EnableInfVerif=false ` /p:RunApiValidator=false ` /verbosity:minimal if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - 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 foreach ($file in @("MttVDD.dll", "MttVDD.inf", "MttVDD.cat", "vdd_settings.xml")) { Copy-Item -LiteralPath (Join-Path $outDir $file) -Destination (Join-Path $dest $file) } $inf = Join-Path $dest "MttVDD.inf" if (-not (Select-String -Path $inf -Pattern "^UmdfLibraryVersion\s*=\s*$([regex]::Escape($env:UMDF_VERSION))\.0\s*$" -Quiet)) { throw "The packaged INF does not use UMDF $env:UMDF_VERSION" } if (-not (Select-String -Path $inf -Pattern "^DriverVer\s*=\s*$([regex]::Escape($env:VDD_DRIVER_VER))\s*$" -Quiet)) { throw "The packaged INF does not have the expected DriverVer $env:VDD_DRIVER_VER" } - name: Upload unsigned driver package id: unsigned_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_RELEASE_RUN == 'true' shell: pwsh env: SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }} SIGNPATH_ORG_ID: ${{ vars.SIGNPATH_ORG_ID }} run: | foreach ($name in @('SIGNPATH_API_TOKEN', 'SIGNPATH_ORG_ID')) { if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) { throw "Missing GitHub repository configuration: $name" } } - name: Request SignPath release signing id: signpath if: env.SIGNPATH_RELEASE_RUN == 'true' uses: signpath/github-action-submit-signing-request@a2c5b60d9c75f073142b653c354b632eedce097b # v3.2 with: api-token: ${{ secrets.SIGNPATH_API_TOKEN }} organization-id: ${{ vars.SIGNPATH_ORG_ID }} project-slug: Virtual-Display-Driver signing-policy-slug: release-signing artifact-configuration-slug: vdd_driver_only github-artifact-id: ${{ steps.unsigned_package.outputs.artifact-id }} github-token: ${{ github.token }} wait-for-completion: true wait-for-completion-timeout-in-seconds: 3600 output-artifact-directory: signed-artifacts/VDD/${{ matrix.platform }}/ - name: Verify release signatures and catalog membership if: env.SIGNPATH_RELEASE_RUN == 'true' shell: pwsh run: | $ErrorActionPreference = "Stop" $root = "signed-artifacts\VDD\${{ matrix.platform }}" foreach ($file in @('MttVDD.dll', 'MttVDD.inf', 'MttVDD.cat', 'vdd_settings.xml')) { if (-not (Test-Path -LiteralPath (Join-Path $root $file) -PathType Leaf)) { throw "Missing file in the signed driver package: $file" } } $signtool = Join-Path $env:WINDOWS_SDK_DIR "bin\$env:WINDOWS_TARGET_PLATFORM_VERSION\x64\signtool.exe" if (-not (Test-Path -LiteralPath $signtool -PathType Leaf)) { throw "SignTool not found: $signtool" } $catalog = Join-Path $root 'MttVDD.cat' $driver = Join-Path $root 'MttVDD.dll' $inf = Join-Path $root 'MttVDD.inf' & $signtool verify /pa /v $catalog $driver if ($LASTEXITCODE -ne 0) { throw 'Release signature verification failed' } foreach ($file in @($inf, $driver)) { & $signtool verify /pa /v /c $catalog $file if ($LASTEXITCODE -ne 0) { throw "Catalog membership verification failed: $file" } } - name: Upload verified release-signed driver package if: env.SIGNPATH_RELEASE_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: Link the signing request if: ${{ always() && steps.signpath.outputs.signing-request-web-url != '' }} shell: pwsh env: SIGNING_REQUEST_URL: ${{ steps.signpath.outputs.signing-request-web-url }} run: | "[SignPath request for ${{ matrix.platform }}]($env:SIGNING_REQUEST_URL)" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append control-panel: if: github.event_name == 'workflow_dispatch' && inputs.control_ref != '' runs-on: windows-2022 defaults: run: shell: pwsh steps: - name: Validate the Control commit env: CONTROL_REF: ${{ inputs.control_ref }} SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }} SIGNPATH_ORG_ID: ${{ vars.SIGNPATH_ORG_ID }} run: | if ($env:CONTROL_REF -cnotmatch '^[0-9a-f]{40}$') { throw 'Provide the full commit SHA from VirtualDrivers/Virtual-Driver-Control.' } if ($env:SIGNPATH_RELEASE_RUN -ne 'true') { throw 'Select release signing for the Control package.' } if (!$env:SIGNPATH_API_TOKEN -or !$env:SIGNPATH_ORG_ID) { throw 'SignPath is not configured.' } - name: Check out the Control source uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: repository: VirtualDrivers/Virtual-Driver-Control ref: ${{ inputs.control_ref }} persist-credentials: false - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: node-version: 24 cache: npm cache-dependency-path: VirtualDriverControl/package-lock.json - name: Build the Windows application working-directory: VirtualDriverControl env: CONTROL_REF: ${{ inputs.control_ref }} run: | $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true $actualRef = git rev-parse HEAD if ($actualRef -ne $env:CONTROL_REF) { throw 'The checked-out Control commit does not match the requested SHA.' } "Control source: https://github.com/VirtualDrivers/Virtual-Driver-Control/commit/$actualRef" >> $env:GITHUB_STEP_SUMMARY npm ci npm run typecheck npm run build npm exec -- electron-builder --win --x64 --dir --publish never '-c.win.signExecutable=false' New-Item -ItemType Directory -Path 'sign-application' | Out-Null Copy-Item 'dist\win-unpacked\Virtual Driver Control.exe' 'sign-application\Virtual Driver Control.exe' - name: Upload the unpacked application executable id: control_application uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: Control-x64-application-unsigned path: VirtualDriverControl/sign-application/ if-no-files-found: error - name: Sign the application executable through SignPath id: sign_control_application uses: signpath/github-action-submit-signing-request@a2c5b60d9c75f073142b653c354b632eedce097b # v3.2 with: api-token: ${{ secrets.SIGNPATH_API_TOKEN }} organization-id: ${{ vars.SIGNPATH_ORG_ID }} project-slug: Virtual-Display-Driver signing-policy-slug: release-signing artifact-configuration-slug: control_panel github-artifact-id: ${{ steps.control_application.outputs.artifact-id }} github-token: ${{ github.token }} wait-for-completion: true wait-for-completion-timeout-in-seconds: 3600 output-artifact-directory: VirtualDriverControl/signed-application/ - name: Package the signed application as a portable executable working-directory: VirtualDriverControl run: | $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true $application = 'signed-application\Virtual Driver Control.exe' $sig = Get-AuthenticodeSignature -LiteralPath $application if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notmatch '(^|,\s*)CN=SignPath Foundation(,|$)') { throw "The unpacked application does not have the expected signature ($($sig.Status))." } Copy-Item -LiteralPath $application -Destination 'dist\win-unpacked\Virtual Driver Control.exe' -Force Get-FileHash -LiteralPath $application | Format-List npm exec -- electron-builder --win portable --x64 --prepackaged dist/win-unpacked --publish never '-c.win.signExecutable=false' '-c.win.artifactName=Virtual Driver Control.exe' New-Item -ItemType Directory -Path 'sign-portable' | Out-Null Move-Item -LiteralPath 'dist\Virtual Driver Control.exe' -Destination 'sign-portable\Virtual Driver Control.exe' - name: Upload the portable executable id: control_portable uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: Control-x64-portable-unsigned path: VirtualDriverControl/sign-portable/ if-no-files-found: error - name: Sign the portable executable through SignPath id: sign_control_portable uses: signpath/github-action-submit-signing-request@a2c5b60d9c75f073142b653c354b632eedce097b # v3.2 with: api-token: ${{ secrets.SIGNPATH_API_TOKEN }} organization-id: ${{ vars.SIGNPATH_ORG_ID }} project-slug: Virtual-Display-Driver signing-policy-slug: release-signing artifact-configuration-slug: control_panel github-artifact-id: ${{ steps.control_portable.outputs.artifact-id }} github-token: ${{ github.token }} wait-for-completion: true wait-for-completion-timeout-in-seconds: 3600 output-artifact-directory: VirtualDriverControl/signed-portable/ - name: Verify the signed portable executable run: | $exe = 'VirtualDriverControl\signed-portable\Virtual Driver Control.exe' $sig = Get-AuthenticodeSignature -LiteralPath $exe if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notmatch '(^|,\s*)CN=SignPath Foundation(,|$)') { throw "The portable executable does not have the expected signature ($($sig.Status))." } $hash = (Get-FileHash -LiteralPath $exe).Hash "Portable executable SHA-256: $hash" >> $env:GITHUB_STEP_SUMMARY - name: Upload the signed Control package uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: Virtual-Driver-Control-x64-signed path: VirtualDriverControl/signed-portable/ if-no-files-found: error