From 1678f390fc5e60513ab0bb9e755b9460f6fa466a Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Sun, 15 Sep 2024 00:15:16 +1000 Subject: [PATCH] [#111] Add support for HL7 Spy Adds a plugin Get-InnerHarbourHL7Spy.ps1 and a new private function Parse-SemVer for interrogating SemVers. https://hl7spy.ca/blog/ --- Nevergreen/Apps/Get-InnerHarbourHL7Spy.ps1 | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Nevergreen/Apps/Get-InnerHarbourHL7Spy.ps1 diff --git a/Nevergreen/Apps/Get-InnerHarbourHL7Spy.ps1 b/Nevergreen/Apps/Get-InnerHarbourHL7Spy.ps1 new file mode 100644 index 0000000..3c557a5 --- /dev/null +++ b/Nevergreen/Apps/Get-InnerHarbourHL7Spy.ps1 @@ -0,0 +1,58 @@ +$AppName = "HL7Spy" + +$Arch = "x64" # Apparently the only supported one. +$ReleaseUrl = "https://hl7spy.ca/blog/" +$ReleaseNotesUrl = "https://hl7spy.ca/release-history/" # N.B. This does not always appear to be kept upto date. +$InstallInstructionsUrl = "https://conevity.atlassian.net/wiki/spaces/HL7Spy4/pages/626065447/Download+Installation" + +Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n" + +$AppVersions = @( + @{AppName = "$($AppName)"; Type = 'exe'; URLPattern = 'HL7Spy\.(\d+\.\d+(\.\d+))'} +) + +foreach ($AppVersion in $AppVersions) { + + # Get all matching URLs + $URLs = Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $AppVersion.URLPattern | + Set-UriPrefix -Prefix 'https://hl7spy.ca/' + + if (-not $URLs) { + Write-Warning "Could not find release for $($AppVersion.AppName) $($AppVersion.Type)" + continue + } + + # Get versions from URLs + $VersionUrlPairs = @() + foreach ($Url in $URLs) { + $VerString = Get-Version -String $Url + + try { + $VersionObj = [version]$VerString + $VersionUrlPairs += [PSCustomObject]@{ + Version = $VersionObj + Url = $Url + } + } catch { + Write-Warning "Invalid version format '$VerString' for URL '$Url'" + } + } + + if (-not $VersionUrlPairs) { + Write-Warning "Could not extract valid versions for $($AppVersion.AppName) $($AppVersion.Type)" + continue + } + + # Sort versions descending using [version] comparison + $HighestVersionPair = $VersionUrlPairs | Sort-Object -Property Version -Descending | Select-Object -First 1 + + New-NevergreenApp -Name $($AppVersion.AppName) ` + -Architecture $Arch ` + -Version $($HighestVersionPair.Version) ` + -Uri $($HighestVersionPair.Url) ` + -Type $($AppVersion.Type) +} + +Write-Verbose "" +Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)" +Write-Verbose "$($AppName) (Version: $($Version)) Release notes are available here: $($ReleaseNotesUrl)"