@@ -5,7 +5,7 @@ function Get-mySQLWorkbench {
55 Twitter: @stealthpuppy
66 #>
77 [OutputType ([System.Management.Automation.PSObject ])]
8- [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSUseSingularNouns" , " " , Justification= " Product name is a plural" )]
8+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSUseSingularNouns" , " " , Justification = " Product name is a plural" )]
99 [CmdletBinding (SupportsShouldProcess = $False )]
1010 param (
1111 [Parameter (Mandatory = $False , Position = 0 )]
@@ -14,24 +14,29 @@ function Get-mySQLWorkbench {
1414 $res = (Get-FunctionResource - AppName (" $ ( $MyInvocation.MyCommand ) " .Split(" -" ))[1 ])
1515 )
1616
17- # Pass the repo releases API URL and return a formatted object
18- $params = @ {
19- Uri = $res.Get.Update.Uri
20- MatchVersion = $res.Get.Update.MatchVersion
21- Filter = $res.Get.Update.MatchFileTypes
22- ReturnVersionOnly = $True
23- }
24- $object = Get-GitHubRepoRelease @params
17+ # Get latest repo tag
18+ $Tags = Get-GitHubRepoTag - Uri $res.Get.Update.Uri
19+
20+ $Version = ($Tags | Sort-Object - Property @ { Expression = { [System.Version ]$_.Tag }; Descending = $true } | Select-Object - First 1 ).Tag
2521
2622 # Build the output object
27- if ($Null -ne $object ) {
23+ if ($Null -ne $Version ) {
2824 foreach ($Architecture in $res.Get.Download.Uri.GetEnumerator ()) {
29- $Uri = $res.Get.Download.Uri [$Architecture.Key ] -replace $res.Get.Download.ReplaceText , $object.Version
25+
26+ # https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-8.0.40-winx64.msi
27+ # redirect to
28+ # https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.40-winx64.msi
29+ #
30+ # The version ist major.minor.patch, while the tag can have also have major.minor.patch.build
31+ $Uri = $res.Get.Download.Uri [$Architecture.Key ] -replace $res.Get.Download.ReplaceVersion , (($Version -split ' \.' )[0 .. 2 ] -join ' .' )
32+
33+ $CdnUri = (Invoke-WebRequest $Uri - MaximumRedirection 0 - SkipHttpErrorCheck - ErrorAction:SilentlyContinue).Headers.Location[0 ]
34+
3035 $PSObject = [PSCustomObject ] @ {
31- Version = $object . Version
36+ Version = $Version
3237 Type = Get-FileType - File $Uri
3338 Architecture = $Architecture.Name
34- URI = $Uri
39+ URI = $CdnUri
3540 }
3641 Write-Output - InputObject $PSObject
3742 }
0 commit comments