-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First attempt at filing bugs if WDK is out-of-date Signed-off-by: Alan Jowett <[email protected]> * Update .github/workflows/check_wdk.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update .github/workflows/check_wdk.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update Signed-off-by: Alan Jowett <[email protected]> * Fix script Signed-off-by: Alan Jowett <[email protected]> * Add mitigiation steps Signed-off-by: Alan Jowett <[email protected]> --------- Signed-off-by: Alan Jowett <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
57de7c4
commit 6a4b9aa
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright (c) eBPF for Windows contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
# This workflow checks for Windows Driver Kit updates and files issues when updates are needed. | ||
|
||
name: Check for updates to the Windows Driver Kit | ||
|
||
on: | ||
# Run script every Sunday at midnight | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
# Allow manual triggering of the script | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check: | ||
runs-on: Windows-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
|
||
- name: Check for updates to the Windows Driver Kit | ||
id: check_wdk | ||
run: | | ||
# Get the latest version of the Windows Driver Kit | ||
$packageVersion = .\scripts\Get-LatestNugetPackageVersion.ps1 -PackageName "Microsoft.Windows.WDK.x64" | ||
"wdk_version=$packageVersion" >> $env:GITHUB_OUTPUT | ||
- name: Check the version of the WDK in the repo | ||
id: check_repo_wdk | ||
run: | | ||
$wdkVersion = (Get-Content -Path .\wdk.props | Select-String -Pattern "<WDKVersion>" | ForEach-Object { $_ -replace "<WDKVersion>", "" -replace "</WDKVersion>", "" }).trim() | ||
"wdk_version=$wdkVersion" >> $env:GITHUB_OUTPUT | ||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea | ||
if: steps.check_wdk.outputs.wdk_version != steps.check_repo_wdk.outputs.wdk_version | ||
env: | ||
TITLE: 'Update the Windows Driver Kit' | ||
BODY: | | ||
The Windows Driver Kit version in the repository does not match the latest version available on NuGet. Please update the WDK version in the repository to match the latest version available on NuGet. | ||
The latest version is ${{steps.check_wdk.outputs.wdk_version}} and the version in the repository is ${{steps.check_repo_wdk.outputs.wdk_version}}. | ||
To update the WDK run the following command: | ||
```powershell | ||
.\scripts\Update-WdkVersion.ps1 | ||
``` | ||
LABELS: bug,ci/cd | ||
with: | ||
script: | | ||
const owner = process.env.GITHUB_REPOSITORY.split('/')[0] | ||
const repo = process.env.GITHUB_REPOSITORY.split('/')[1] | ||
const body = process.env.BODY; | ||
const title = process.env.TITLE; | ||
const labels = process.env.LABELS; | ||
const label_array = labels ? labels.split(',') : []; | ||
console.log(label_array); | ||
// Get all issues that have these labels. | ||
const opts = github.rest.issues.listForRepo.endpoint.merge({ | ||
...context.issue, | ||
state: 'open', | ||
labels: label_array, | ||
}); | ||
const issues = await github.paginate(opts); | ||
// Look for an existing issue with the same title. | ||
for (const issue of issues) { | ||
if (issue.title === title) { | ||
console.log(`Updating issue ${title}`); | ||
await github.rest.issues.createComment({ | ||
issue_number: issue.number, | ||
owner, | ||
repo, | ||
body, | ||
}); | ||
return; | ||
} | ||
} | ||
// Existing issue not found, create a new one. | ||
console.log(`Creating issue ${title}`); | ||
await github.rest.issues.create({ | ||
owner: owner, | ||
repo: repo, | ||
title: title, | ||
body: body, | ||
labels: label_array, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) eBPF for Windows contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
param( | ||
[string]$packageName | ||
) | ||
|
||
<# | ||
.SYNOPSIS | ||
Get the latest version of a NuGet package. | ||
.DESCRIPTION | ||
Queries the NuGet package manager for the latest version of a package. | ||
.PARAMETER packageName | ||
The name of the package to query. | ||
.NOTES | ||
This function requires the 'nuget' command to be available in the PATH. | ||
#> | ||
|
||
function Get-LatestNugetPackageVersion( | ||
[string]$packageName | ||
) { | ||
if ([string]::IsNullOrWhiteSpace($packageName)) { | ||
throw "Package name cannot be empty" | ||
} | ||
|
||
try { | ||
$package = nuget list $packageName | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to retrieve package information" | ||
} | ||
$packageLine = $package | Where-Object { $_ -match $packageName } | ||
if (-not $packageLine) { | ||
throw "Package '$packageName' not found" | ||
} | ||
if ($packageLine -is [array]) { | ||
$packageLine = $packageLine[0] | ||
} | ||
$version = $packageLine -replace "$packageName\s+", "" | ||
return $version | ||
} catch { | ||
throw "Failed to retrieve version of package '$packageName': $_" | ||
} | ||
} | ||
|
||
# Get the latest version of the Microsoft.Windows.WDK.x64 package | ||
Get-LatestNugetPackageVersion $packageName |