Skip to content

Commit

Permalink
add update script (#156)
Browse files Browse the repository at this point in the history
Co-authored-by: Laksh Kotian <[email protected]>
  • Loading branch information
LakshK98 and Laksh Kotian authored Nov 11, 2024
1 parent 7f5efcc commit 512a85f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions scripts/update-product-version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) eBPF for Windows contributors
# SPDX-License-Identifier: MIT

param ($majorVersion, $minorVersion, $revisionNumber)

# Check if the version number is in the format X.Y.Z
if ("$majorVersion.$minorVersion.$revisionNumber" -match '^\d+\.\d+\.\d+$') {

if (Test-Path -Path ".\ntosebpfext.sln") {
# Set the new version number in the Directory.Build.props file.
$ntosebpfext_build_prop_file = "$PSScriptRoot\..\Directory.Build.props"
Write-Host -ForegroundColor DarkGreen "Updating the version number in the '$ntosebpfext_build_prop_file' file..."
# Replace <eBPFExtensionsVersionMajor>0</eBPFExtensionsVersionMajor> with <eBPFExtensionsVersionMajor>$majorVersion</eBPFExtensionsVersionMajor>
$newcontent = (Get-Content $ntosebpfext_build_prop_file -Raw -Encoding UTF8) `
-replace '(?<=<eBPFExtensionsVersionMajor>)\d+', $majorVersion `
-replace '(?<=<eBPFExtensionsVersionMinor>)\d+', $minorVersion `
-replace '(?<=<eBPFExtensionsVersionRevision>)\d+', $revisionNumber
$newcontent | Set-Content $ntosebpfext_build_prop_file -NoNewline
Write-Host -ForegroundColor DarkGreen "Version number updated to '$majorVersion.$minorVersion.$revisionNumber' in $ntosebpfext_build_prop_file"

# Set the new version number in the ebpf_ext_version.h file.
$ntosebpfext_version_file = "$PSScriptRoot\..\resource\ebpf_ext_version.h"
# Replace #define EBPF_VERSION_MAJOR 0 with #define EBPF_VERSION_MAJOR $majorVersion
$newcontent = (Get-Content $ntosebpfext_version_file -Raw -Encoding UTF8) `
-replace '(?<=#define EBPF_VERSION_MAJOR )\d+', $majorVersion `
-replace '(?<=#define EBPF_VERSION_MINOR )\d+', $minorVersion `
-replace '(?<=#define EBPF_VERSION_REVISION )\d+', $revisionNumber
$newcontent | Set-Content $ntosebpfext_version_file -NoNewline
Write-Host -ForegroundColor DarkGreen "Version number updated to '$majorVersion.$minorVersion.$revisionNumber' in $ntosebpfext_version_file"

} else {
Write-Host -ForegroundColor Red "'ntosebpfext.sln' not found in the current path."
Write-Host -ForegroundColor DarkYellow "Please run this script from the root directory of the repository, within a Developer Poweshell for VS 2022."
}
} else {
Write-Host -ForegroundColor Red "Invalid version number format. Please enter the version number in the format 'X Y Z', e.g.:"
Write-Host
Write-Host -ForegroundColor DarkGreen " PS> .\scripts\update-product-version.ps1 0 9 0"
Write-Host
}

0 comments on commit 512a85f

Please sign in to comment.