Skip to content

Commit 3b5438e

Browse files
Fix Linux and macOS infinite loops
1 parent ca66e82 commit 3b5438e

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

.github/workflows/Action-Test.yml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,15 @@ jobs:
7171
Write-Host "Resolved 'latest' → $requested"
7272
}
7373
74-
# Parse the major version from the requested version string
75-
$majorVersion = $requested -replace '-.*$', '' | ForEach-Object { ($_ -split '\.')[0] }
76-
Write-Host "Detected major version: $majorVersion"
77-
78-
# Determine the installation directory based on preview vs stable
79-
$isPreview = '${{ matrix.version }}'.Trim().ToLower() -eq 'preview' -or $requested -match '-preview\.'
80-
if ($isPreview) {
81-
$installDir = "$majorVersion-preview"
74+
# Actual version installed by the action
75+
if ($IsWindows) {
76+
$majorVersion = ($requested -split '[\.-]')[0]
77+
$installDir = if ($requested -match 'preview') { "$majorVersion-preview" } else { $majorVersion }
78+
$installed = (& "$env:ProgramFiles\PowerShell\$installDir\pwsh.exe" -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
8279
} else {
83-
$installDir = "$majorVersion"
84-
}
85-
86-
$pwshPath = "$env:ProgramFiles\PowerShell\$installDir\pwsh.exe"
87-
Write-Host "Expected pwsh location: $pwshPath"
88-
89-
# Verify the file exists
90-
if (-not (Test-Path $pwshPath)) {
91-
Write-Host "ERROR: PowerShell executable not found at expected path: $pwshPath"
92-
Write-Host "`nSearching for all pwsh.exe installations..."
93-
Get-ChildItem "$env:ProgramFiles\PowerShell" -Recurse -Filter "pwsh.exe" -ErrorAction SilentlyContinue |
94-
ForEach-Object { Write-Host " Found: $($_.FullName)" }
95-
throw "PowerShell executable not found at: $pwshPath"
80+
$installed = (pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
9681
}
9782
98-
# Get the version from the installed executable
99-
$installed = (& $pwshPath -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
10083
Write-Host "Installed PowerShell version: $installed"
10184
Write-Host "Expected PowerShell version: $requested"
10285

0 commit comments

Comments
 (0)