Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion .github/workflows/scripts/windows/swift/install-swift.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,50 @@ function Install-Swift {
exit 1
}
Remove-FileWithRetry -Path installer.exe
}

Write-Host -NoNewLine 'Adding Swift to PATH ... '
# Older toolchains modify the Machine PATH to include \Library\Developer\Toolchains
foreach ($Item in [Environment]::GetEnvironmentVariables('Machine')['Path'].Split(';')) {
if ($Item.Contains('Swift') -or $Item.Contains('Library\Developer\Toolchains')) {
GitHubActions-AddPath -Item $Item
}
}
# Newer toolchains modify the User PATH to include a path to a Swift directory
foreach ($Item in [Environment]::GetEnvironmentVariables('User')['Path'].Split(';')) {
if ($Item.Contains('Swift')) {
GitHubActions-AddPath -Item $Item
}
}
# Find and export the SDKROOT environment variable
$MachineSDKROOT = [Environment]::GetEnvironmentVariables('Machine')['SDKROOT']
$UserSDKROOT = [Environment]::GetEnvironmentVariables('User')['SDKROOT']
if ($MachineSDKROOT) {
GitHubActions-ExportVariable -Name "SDKROOT" -Value $MachineSDKROOT
} elseif ($UserSDKROOT) {
GitHubActions-ExportVariable -Name "SDKROOT" -Value $UserSDKROOT
}
Write-Host 'SUCCESS'
}

function GitHubActions-AddPath {
param (
[string]$Item
)
$FilePath = $env:GITHUB_PATH
if ($FilePath) {
Add-Content -Path "$FilePath" -Value "$Item`r`n"
}
$env:Path = $Item + ";" + $env:Path
}

function GitHubActions-ExportVariable {
param (
[string]$Name,
[string]$Value
)
$FilePath = $env:GITHUB_ENV
if ($FilePath) {
Add-Content -Path "$FilePath" -Value "$Name=$Value`r`n"
}
Set-Content env:\$Name $Value
}
11 changes: 7 additions & 4 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,12 @@ jobs:
}
docker pull $Image
echo "image=$Image" >> "$env:GITHUB_OUTPUT"
- name: "Install Python 3.10"
if: ${{ !inputs.enable_windows_docker }}
uses: actions/setup-python@v6
with:
python-version: "3.10"
architecture: "x86"
- name: Install Visual Studio Build Tools
if: ${{ !inputs.enable_windows_docker }}
run: . ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/windows/install-vsb.ps1
Expand Down Expand Up @@ -730,7 +736,4 @@ jobs:
- name: Build / Test
timeout-minutes: 60
if: ${{ !inputs.enable_windows_docker }}
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
RefreshEnv
powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode
run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode