Skip to content

Commit 2bfefc6

Browse files
committed
GHA: add the ability to update the module map
Introduce a new option to update the Windows SDK modularization to the latest version in Swift.
1 parent 461d602 commit 2bfefc6

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed

.github/workflows/test-install.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,26 @@ jobs:
6969
shell: pwsh
7070
run: |
7171
-not (Get-Command sourcekit-lsp.exe -ErrorAction SilentlyContinue)
72+
73+
windows-update-sdk-modules:
74+
name: Test SDK module updates on Windows
75+
runs-on: windows-latest
76+
77+
steps:
78+
- uses: actions/checkout@v3
79+
- uses: compnerd/gha-setup-vsdevenv@main
80+
81+
- name: Install Swift with SDK module updates
82+
uses: ./
83+
with:
84+
swift-version: swift-5.5-release
85+
swift-build: 5.5-RELEASE
86+
update-sdk-modules: true
87+
88+
- name: Verify Swift installation
89+
run: swift --version
90+
91+
- name: Smoke test
92+
run: |
93+
swift package init --type executable
94+
swift build

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ jobs:
5353
- `swift-version`: (**Note:** this is not a git branch name) the Swift "version" to be installed. This may be either a pre-release branch (e.g. `swift-5.5-branch`), a release branch (e.g. `swift-5.5-release`) or the development branch (`swift-development`).
5454
- `swift-build`: (**Note:** this is not a git tag name) the actual build tag to install, minus the "`swift-`" prefix. May indicate a release snapshot (e.g. `5.5-DEVELOPMENT-SNAPSHOT-2021-09-18-a`), development snapshot (e.g. `DEVELOPMENT-SNAPSHOT-2021-09-28-a`), or a release (e.g. `5.5-RELEASE`).
5555

56-
#### Deprecated Parameters (will be removed in a future version):
57-
- `branch`: **[DEPRECATED]** Use `swift-version` instead.
58-
- `tag`: **[DEPRECATED]** Use `swift-build` instead.
59-
6056
#### When using Swift builds from a Github repository release:
6157
- `github-repo`: Github repo in "owner/repo" format
6258
- `release-tag-name`: Release tag name, can be found in `github.com/<owner>/<repo>/releases`
6359
- `release-asset-name`: Asset name for the Swift installer executable in the release
6460
- `github-token`: Optional Github token for fetching a release from a private repository
61+
62+
#### Additional Options:
63+
- `update-sdk-modules`: Update SDK module definitions to latest version after installation (Windows only, default: false)
64+
- `installer-args`: Additional arguments to pass to the installer, space-delimited
65+
66+
#### Deprecated Parameters (will be removed in a future version):
67+
- `branch`: **[DEPRECATED]** Use `swift-version` instead.
68+
- `tag`: **[DEPRECATED]** Use `swift-build` instead.

action.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ inputs:
5050
description: 'Additional arguments to pass to the installer, space-delimited (double quotes are not supported)'
5151
required: false
5252
default: ''
53+
update-sdk-modules:
54+
description: 'Update SDK module definitions to latest version after installation (Windows only)'
55+
required: false
56+
default: 'false'
57+
type: boolean
5358

5459
runs:
5560
using: 'composite'
@@ -216,6 +221,48 @@ runs:
216221
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
217222
shell: pwsh
218223

224+
- name: Update SDK Module Definitions
225+
if: runner.os == 'Windows' && inputs.update-sdk-modules == 'true'
226+
run: |
227+
Write-Host "::notice::Updating SDK module definitions to latest version..."
228+
229+
$SwiftRoot = Split-Path -Path (Split-Path -Path (Get-Command swift).Source -Parent) -Parent
230+
231+
$ModuleDefinitions = @{
232+
"WinSDK(UM) Module Map" = @{
233+
URL = "https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/winsdk.modulemap";
234+
Destination = "$([IO.Path]::Combine("${env:SDKROOT}", "usr", "share", "winsdk.modulemap"))";
235+
};
236+
"UCRT Module Map" = @{
237+
URL = "https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/ucrt.modulemap";
238+
Destination = "$([IO.Path]::Combine("${env:SDKROOT}", "usr", "share", "ucrt.modulemap"))";
239+
};
240+
"VCRuntime Module Map" = @{
241+
URL = "https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/vcruntime.modulemap";
242+
Destination = "$([IO.Path]::Combine("${env:SDKROOT}", "usr", "share", "vcruntime.modulemap"))";
243+
};
244+
"VCRuntime API Notes" = @{
245+
URL = "https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/vcruntime.apinotes";
246+
Destination = "$([IO.Path]::Combine("${env:SDKROOT}", "usr", "share", "vcruntime.apinotes"))";
247+
};
248+
"Clang Module Map" = @{
249+
URL = "https://raw.githubusercontent.com/llvm/llvm-project/main/clang/lib/Headers/module.modulemap";
250+
Destination = "$([IO.Path]::Combine("$SwiftRoot", "lib", "swift", "clang", "include", "module.modulemap"))";
251+
};
252+
}
253+
254+
$ModuleDefinitions.GetEnumerator() | ForEach-Object {
255+
Write-Host "::notice::Updating $($_.Value.Destination)"
256+
curl.exe --fail --silent --show-error --retry 3 --retry-delay 5 --output "$($_.Value.Destination)" --location $_.Value.URL
257+
if ($LASTEXITCODE -ne 0) {
258+
Write-Host "::error::Failed to update $($_.Key)"
259+
exit 1
260+
}
261+
}
262+
263+
Write-Host "::notice::SDK module definitions updated successfully"
264+
shell: pwsh
265+
219266
- name: Install Swift
220267
if: runner.os == 'Linux'
221268
run: |

0 commit comments

Comments
 (0)