Skip to content

Commit 9955d59

Browse files
kendalcompnerd
authored andcommitted
Skip VS 2022 compatibility setup if toolchain is newer than 5.9
1 parent 81f383b commit 9955d59

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

action.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,36 @@ runs:
227227
Get-ChildItem Env: | % { echo "$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append }
228228
shell: pwsh
229229

230-
- name: VS2022 Compatibility Setup
230+
- name: Check Swift version
231231
if: runner.os == 'Windows'
232+
id: swift-version
233+
shell: pwsh
234+
run: |
235+
$SwiftVersionOutput=$(swift --version)
236+
if ("$SwiftVersionOutput" -match "[\d]+(\.[\d]+){0,2}") {
237+
$SwiftSemVer=$Matches[0]
238+
239+
# Ensure we have at least MAJOR.MINOR or [System.Version] won't parse.
240+
if (-Not ($SwiftSemVer -like "*.*")) {
241+
$SwiftSemVer += ".0"
242+
}
243+
244+
$SwiftVersion=[System.Version]($SwiftSemVer)
245+
246+
# If the toolchain is newer than 5.9 we don't need to ensure compatibility with VS2022.
247+
if ($SwiftVersion -gt [System.Version]"5.9") {
248+
"is_newer_than_5_9='true'" | Out-File $env:GITHUB_OUTPUT -Append -Encoding utf8
249+
} else {
250+
"is_newer_than_5_9='false'" | Out-File $env:GITHUB_OUTPUT -Append -Encoding utf8
251+
}
252+
}
253+
254+
- name: VS2022 Compatibility Setup
255+
if: runner.os == 'Windows' && steps.swift-version.outputs.is_newer_than_5_9 == 'false'
232256
uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # v6
233257

234258
- name: VS2022 Compatibility Installation
235-
if: runner.os == 'Windows'
259+
if: runner.os == 'Windows' && steps.swift-version.outputs.is_newer_than_5_9 == 'false'
236260
run: |
237261
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
238262
if (Test-Path -Path "$env:SDKROOT\usr\share\vcruntime.modulemap") {

0 commit comments

Comments
 (0)