@@ -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,14 +108,39 @@ 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"
102121
122+ # Derive the Swift version and repository from the inputs.
123+ if ($SwiftVersion -ne "") {
124+ if ($SwiftRepo -eq "") {
125+ $SwiftBranch = "swift-${SwiftVersion}-release"
126+ $SwiftTag = "${SwiftVersion}-RELEASE"
127+ Write-Output "ℹ️ Using upstream Swift toolchain: $SwiftVersion (branch: $SwiftBranch, tag: $SwiftTag)"
128+ } else {
129+ # Note: This only supports Windows for now.
130+ $SwiftReleaseAssetName = "installer-${BuildArch}.exe"
131+ $SwiftReleaseTagName = "swift-${SwiftVersion}"
132+ Write-Output "ℹ️ Using custom Swift toolchain: $SwiftVersion (repository: $SwiftRepo, tag: $SwiftReleaseTagName, asset: $SwiftReleaseAssetName)"
133+ }
134+ }
135+
103136 @"
104137 build-os=$BuildOS
105138 build-arch=$BuildArch
106139 host-arch=$HostArch
140+ swift-branch=$SwiftBranch
141+ swift-tag=$SwiftTag
142+ swift-release-asset=$SwiftReleaseAssetName
143+ swift-release-tag=$SwiftReleaseTagName
107144 "@ | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
108145
109146 - name : Install Windows SDK version ${{ inputs.windows-sdk-version }}
@@ -257,3 +294,19 @@ runs:
257294 arch : ${{ steps.sanitize-input.outputs.host-arch }}
258295 winsdk : ${{ inputs.windows-sdk-version }}
259296 toolset_version : ${{ inputs.msvc-version }}
297+
298+ - name : Setup Swift toolchain (Upstream)
299+ if : inputs.swift-version != '' && inputs.swift-repo == ''
300+ uses : compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
301+ with :
302+ branch : ${{ steps.sanitize-input.outputs.swift-branch }}
303+ tag : ${{ steps.sanitize-input.outputs.swift-tag }}
304+
305+ - name : Setup Swift toolchain (Custom)
306+ if : inputs.swift-version != '' && inputs.swift-repo != ''
307+ uses : compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
308+ with :
309+ github-repo : ${{ inputs.swift-repo }}
310+ github-token : ${{ github.token }}
311+ release-asset-name : ${{ steps.sanitize-input.outputs.swift-release-asset }}
312+ release-tag-name : ${{ steps.sanitize-input.outputs.swift-release-tag }}
0 commit comments