Skip to content

Commit

Permalink
Use system.version to compare versions from github
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Neale committed Dec 27, 2024
1 parent 2917a1c commit cb8db6b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PowerShell/ScubaGear/CheckVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ function Invoke-CheckScubaGearVersionPSGallery {

function Invoke-CheckScubaGearVersionGithub {
$ScubaManifest = Import-PowerShellDataFile (Join-Path -Path $PSScriptRoot -ChildPath 'ScubaGear.psd1' -Resolve -ErrorAction 'Stop' ) -ErrorAction 'Stop'
$CurrentVersion = $ScubaManifest.ModuleVersion
$LatestVersion = $(Invoke-RestMethod -Uri "https://api.github.com/repos/cisagov/ScubaGear/releases/latest" -ErrorAction 'Stop').tag_name.TrimStart("v")
if ($CurrentVersion -ne $LatestVersion) {
$CurrentVersion = [System.Version]$ScubaManifest.ModuleVersion
$LatestVersion = [System.Version]$(Invoke-RestMethod -Uri "https://api.github.com/repos/cisagov/ScubaGear/releases/latest" -ErrorAction 'Stop').tag_name.TrimStart("v")
if ($CurrentVersion -lt $LatestVersion) {
Write-Warning "A new version of ScubaGear ($latestVersion) is available. Please consider updating at: https://github.com/cisagov/ScubaGear/releases. This notification can be disabled by setting `$env:SCUBAGEAR_SKIP_VERSION_CHECK = `$true before running ScubaGear."
}
}
Expand Down

0 comments on commit cb8db6b

Please sign in to comment.