Skip to content

Commit 5782024

Browse files
Error if swift crashes or version is empty
If the installation fails, `swift --version` will fail to return anything. Catch this early as a failure point rather than continuing onwards and failing later.
1 parent 326f1e7 commit 5782024

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ runs:
198198
id: swift-version
199199
run: |
200200
$Output = swift --version
201+
if ($LASTEXITCODE -ne 0) {
202+
Write-Host "::error::Swift exited with code $LASTEXITCODE"
203+
exit 1
204+
}
205+
if ($Output.Length -eq 0) {
206+
Write-Host "::error::`swift --version` output is empty"
207+
exit 1
208+
}
201209
$Match = ([regex]"\d+.\d+(.\d+)?").Match($Output)
202210
if ($Match.Success) {
203211
$SwiftVersion = [System.Version]($Match.Groups[0].Value)

0 commit comments

Comments
 (0)