-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Issue: There seems to be an issue when trying to generate the XrefMap for Unity 6000.3 as can be seen in the runner logs under https://github.com/NormandErwan/UnityXrefMaps/actions/runs/20540226280/job/59003558970 .
The version is not known in the list and the job exits early.
When trying the steps to get the version for 6000.3, the step Get Unity releases versions and filter in https://github.com/NormandErwan/UnityXrefMaps/blob/main/.github/workflows/unity-xref-maps.yml throws an exception:
New-Object : Exception calling ".ctor" with "1" argument(s): "Version string portion was too short or too long."
At C:\Users\<redacted>\OneDrive\Desktop\XrefMaps.ps1:24 char:20
+ ShortVersion = New-Object System.Version ($_.Name)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
The formatted code is:
$url = 'https://services.api.unity.com/unity/editor/release/v1/releases?' + `
'architecture=X86_64&' + `
'platform=WINDOWS&' + `
'limit=25&' + `
'stream=LTS&' + `
'stream=SUPPORTED&' + `
'stream=TECH'
$response = Invoke-RestMethod $url
$versions = $response.results | Select-Object -ExpandProperty version | ForEach-Object {
$match = [regex]::Match($_, '(?<Version>(?<ShortVersion>(\d+)\.(\d+))\.(\d+))')
@{
RawString = $_
VersionString = $match.Groups['Version'].Value
ShortVersionString = $match.Groups['ShortVersion'].Value
Version = New-Object System.Version ($match.Groups['Version'].Value)
}
} | Group-Object -Property ShortVersionString | ForEach-Object {
[array] $sortedVersions = $_.Group | Sort-Object -Property Version -Descending
@{
ShortVersion = New-Object System.Version ($_.Name) # This line is the cause of the error
RawString = $sortedVersions[0].RawString
VersionString = $sortedVersions[0].VersionString
ShortVersionString = $sortedVersions[0].ShortVersionString
}
} | Sort-Object -Property ShortVersion -Descending | ForEach-Object {
@{
Raw = $_.RawString
ShortVersion = $_.ShortVersionString
}
}
Write-Output "shortVersions=$($versions | Select-Object -ExpandProperty ShortVersion | ConvertTo-Json -Compress)" >> $env:GITHUB_OUTPUT
Write-Output "versions=$($versions | ConvertTo-Json -Compress)" >> $env:GITHUB_OUTPUTThe provided $_.Name is not valid as the ShortVersion because it is just empty:
[DBG]: PS C:\Users\<redacted>>> $response.results | Select-Object -ExpandProperty version | ForEach-Object {
$match = [regex]::Match($_, '(?<Version>(?<ShortVersion>(\d+)\.(\d+))\.(\d+))')
@{
RawString = $_
VersionString = $match.Groups['Version'].Value
ShortVersionString = $match.Groups['ShortVersion'].Value
Version = New-Object System.Version ($match.Groups['Version'].Value)
}
} | Group-Object -Property ShortVersionString
Count Name Group
----- ---- -----
25 {System.Collections.Hashtable, System.Collections.Hashtable, System.Collections.Hashtable, System.Collections.Hashtable...}
Resolution: Use $sortedVersions[0].ShortVersionString instead of $_.Name. It will then return all of the versions:
versions=[{"ShortVersion":"6000.3","Raw":"6000.3.2f1"},{"ShortVersion":"6000.2","Raw":"6000.2.15f1"},{"ShortVersion":"6000.1","Raw":"6000.1.17f1"},{"ShortVersion":"6000.0","Raw":"6000.0.64f1"},{"ShortVersion":"2022.3","Raw":"2022.3.62f3"},{"ShortVersion":"2019.4","Raw":"2019.4.41f2"},{"ShortVersion":"2019.3","Raw":"2019.3.17f1"},{"ShortVersion":"2019.2","Raw":"2019.2.23f1"},{"ShortVersion":"2019.1","Raw":"2019.1.15f1"}]
Metadata
Metadata
Assignees
Labels
No labels