@@ -5,7 +5,7 @@ function Get-mySQLWorkbench {
5
5
Twitter: @stealthpuppy
6
6
#>
7
7
[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" )]
9
9
[CmdletBinding (SupportsShouldProcess = $False )]
10
10
param (
11
11
[Parameter (Mandatory = $False , Position = 0 )]
@@ -14,24 +14,29 @@ function Get-mySQLWorkbench {
14
14
$res = (Get-FunctionResource - AppName (" $ ( $MyInvocation.MyCommand ) " .Split(" -" ))[1 ])
15
15
)
16
16
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
25
21
26
22
# Build the output object
27
- if ($Null -ne $object ) {
23
+ if ($Null -ne $Version ) {
28
24
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
+
30
35
$PSObject = [PSCustomObject ] @ {
31
- Version = $object . Version
36
+ Version = $Version
32
37
Type = Get-FileType - File $Uri
33
38
Architecture = $Architecture.Name
34
- URI = $Uri
39
+ URI = $CdnUri
35
40
}
36
41
Write-Output - InputObject $PSObject
37
42
}
0 commit comments