@@ -22,6 +22,18 @@ inputs:
2222 This is the target architecture for the Visual Studio Developer Environment.
2323 required : false
2424 type : string
25+ swift-version :
26+ description : The Swift version to use, e.g. "6.0.1" for the upstream Apple Swift repository.
27+ Or "6.0.0-20261216.0" for a specific snapshot from another repository.
28+ If unspecified, the Swift toolchain is not set up.
29+ required : false
30+ type : string
31+ swift-repo :
32+ description : |
33+ The Swift repository to use, e.g. "thebrowsercompany/swift-build". If unspecified, and
34+ `swift-version` is specified, the upstream Apple Swift repository is used.
35+ required : false
36+ type : string
2537
2638outputs :
2739 windows-build-tools-version :
@@ -96,6 +108,13 @@ runs:
96108 $HostArch = $BuildArch
97109 }
98110
111+ ${SwiftVersion} = "${{ inputs.swift-version }}"
112+ ${SwiftRepo} = "${{ inputs.swift-repo }}"
113+ if ($SwiftRepo -ne "" -and $SwiftVersion -eq "") {
114+ Write-Output "::error::The `swift-repo` input was specified, but the `swift-version` input was not. Please specify a Swift toolchain version to use."
115+ exit 1
116+ }
117+
99118 Write-Output "ℹ️ Build OS: $BuildOS"
100119 Write-Output "ℹ️ Build architecture: $BuildArch"
101120 Write-Output "ℹ️ Host architecture: $HostArch"
@@ -106,6 +125,28 @@ runs:
106125 host-arch=$HostArch
107126 "@ | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
108127
128+ # Derive the Swift version and repository from the inputs.
129+ if ($SwiftVersion -ne "") {
130+ if ($SwiftRepo -eq "") {
131+ $SwiftBranch = "swift-${SwiftVersion}-release"
132+ $SwiftTag = "${SwiftVersion}-RELEASE"
133+ Write-Output "ℹ️ Using upstream Swift toolchain: $SwiftVersion (branch: $SwiftBranch, tag: $SwiftTag)"
134+ @"
135+ swift-branch=$SwiftBranch
136+ swift-tag=$SwiftTag
137+ "@ | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
138+ } else {
139+ # Note: This only supports Windows for now.
140+ $SwiftReleaseAssetName = "installer-${BuildArch}.exe"
141+ $SwiftReleaseTagName = "swift-${SwiftVersion}"
142+ Write-Output "ℹ️ Using custom Swift toolchain: $SwiftVersion (repository: $SwiftRepo, tag: $SwiftReleaseTagName, asset: $SwiftReleaseAssetName)"
143+ @"
144+ swift-release-tag=$SwiftReleaseTagName
145+ swift-release-asset=$SwiftReleaseAssetName
146+ "@ | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
147+ }
148+ }
149+
109150 - name : Install Windows SDK version ${{ inputs.windows-sdk-version }}
110151 if : steps.sanitize-input.outputs.build-os == 'windows' && inputs.windows-sdk-version != ''
111152 id : setup-windows-sdk
@@ -257,3 +298,19 @@ runs:
257298 arch : ${{ steps.sanitize-input.outputs.host-arch }}
258299 winsdk : ${{ inputs.windows-sdk-version }}
259300 toolset_version : ${{ inputs.msvc-version }}
301+
302+ - name : Setup Swift toolchain (Upstream)
303+ if : inputs.swift-version != '' && inputs.swift-repo == ''
304+ uses : compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
305+ with :
306+ branch : ${{ steps.sanitize-input.outputs.swift-branch }}
307+ tag : ${{ steps.sanitize-input.outputs.swift-tag }}
308+
309+ - name : Setup Swift toolchain (Custom)
310+ if : inputs.swift-version != '' && inputs.swift-repo != ''
311+ uses : compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
312+ with :
313+ github-repo : ${{ inputs.swift-repo }}
314+ github-token : ${{ github.token }}
315+ release-asset-name : ${{ steps.sanitize-input.outputs.swift-release-asset }}
316+ release-tag-name : ${{ steps.sanitize-input.outputs.swift-release-tag }}
0 commit comments