You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rename the `branch` and `tag` to `swift-version` and `swift-build` to
aid in clarity.
Additionally, correct the custom source handling on macOS and Linux.
Fixes: #19
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@ Setup Swift (on Windows) on GitHub Actions Builders
3
3
4
4
Automates installation of the Swift toolchain for Windows hosts on GitHub Actions runners.
5
5
6
-
## Usage
7
-
8
6
> [!NOTE]
9
7
> Windows requires Swift 5.4.2+
10
8
9
+
## Usage
10
+
11
11
* Sample workflow using official Swift releases
12
12
13
13
```yaml
@@ -19,8 +19,8 @@ jobs:
19
19
steps:
20
20
- uses: compnerd/gha-setup-swift@main
21
21
with:
22
-
branch: swift-5.5-release
23
-
tag: 5.5-RELEASE
22
+
swift-version: swift-5.5-release
23
+
swift-build: 5.5-RELEASE
24
24
25
25
- uses: actions/checkout@v2
26
26
- run: swift build
@@ -50,14 +50,15 @@ jobs:
50
50
### Parameters
51
51
52
52
#### When using official Swift releases:
53
-
- `branch`: (**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`).
54
-
- `tag`: (**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`).
53
+
- `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`).
54
+
- `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`).
55
+
56
+
#### Deprecated Parameters (will be removed in a future version):
57
+
- `branch`: **[DEPRECATED]** Use `swift-version` instead.
58
+
- `tag`: **[DEPRECATED]** Use `swift-build` instead.
55
59
56
60
#### When using Swift builds from a Github repository release:
57
61
- `github-repo`: Github repo in "owner/repo" format
58
-
59
62
- `release-tag-name`: Release tag name, can be found in `github.com/<owner>/<repo>/releases`
60
-
61
63
- `release-asset-name`: Asset name for the Swift installer executable in the release
62
-
63
64
- `github-token`: Optional Github token for fetching a release from a private repository
Copy file name to clipboardExpand all lines: action.yml
+87-19Lines changed: 87 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -12,17 +12,25 @@ inputs:
12
12
- custom
13
13
14
14
# for swift.org toolchains:
15
-
branch:
16
-
description: 'Branch for swift.org builds. Only specifiy when using official Swift toolchains from swift.org'
15
+
swift-version:
16
+
description: 'Swift version identifier for swift.org builds (e.g., swift-5.5-release, development). Only specify when using official Swift toolchains from swift.org'
17
17
required: false
18
-
tag:
19
-
description: 'Tag for swift.org builds. Only specifiy when using official Swift toolchains from swift.org'
18
+
swift-build:
19
+
description: 'Swift build identifier for swift.org builds (e.g., 5.5-RELEASE, DEVELOPMENT-SNAPSHOT-2021-09-18-a). Only specify when using official Swift toolchains from swift.org'
20
20
required: false
21
21
build_arch:
22
-
description: 'Build architecture (amd64 or arm64). Only specifiy when using official Swift toolchains from swift.org'
22
+
description: 'Build architecture (amd64 or arm64). Only specify when using official Swift toolchains from swift.org'
description: '[DEPRECATED] Use swift-version instead. Branch for swift.org builds. Only specify when using official Swift toolchains from swift.org'
29
+
required: false
30
+
tag:
31
+
description: '[DEPRECATED] Use swift-build instead. Tag for swift.org builds. Only specify when using official Swift toolchains from swift.org'
32
+
required: false
33
+
26
34
# for custom toolchains:
27
35
github-repo:
28
36
description: 'Github repo in "owner/repo" format. Only specify when using custom toolchains from Github releases.'
@@ -46,6 +54,66 @@ inputs:
46
54
runs:
47
55
using: 'composite'
48
56
steps:
57
+
- name: Handle deprecated parameters and validate inputs
58
+
run: |
59
+
# Handle backward compatibility for deprecated parameters
60
+
$SwiftVersion = "${{ inputs.swift-version }}"
61
+
$SwiftBuild = "${{ inputs.swift-build }}"
62
+
63
+
# Ensure that only the deprecated or the new parameter set is used at one time.
64
+
$errors = @(
65
+
if (![String]::IsNullOrEmpty("${{ inputs.branch }}") -and ![String]::IsNullOrEmpty($SwiftVersion)) { "Cannot specify both 'branch' (deprecated) and 'swift-version'. Please use only 'swift-version'." }
66
+
if (![String]::IsNullOrEmpty("${{ inputs.tag }}") -and ![String]::IsNullOrEmpty($SwiftBuild)) { "Cannot specify both 'tag' (deprecated) and 'swift-build'. Please use only 'swift-build'." }
67
+
)
68
+
foreach ($error in $errors) { Write-Host "::error::$error" }
69
+
if ($errors) { exit 1 }
70
+
71
+
# Handle deprecated parameters with warnings.
72
+
if (![String]::IsNullOrEmpty("${{ inputs.branch }}")) {
73
+
Write-Host "::warning::The 'branch' input is deprecated and will be removed in a future version. Please use 'swift-version' instead."
74
+
$SwiftVersion = "${{ inputs.branch }}"
75
+
}
76
+
77
+
if (![String]::IsNullOrEmpty("${{ inputs.tag }}")) {
78
+
Write-Host "::warning::The 'tag' input is deprecated and will be removed in a future version. Please use 'swift-build' instead."
79
+
$SwiftBuild = "${{ inputs.tag }}"
80
+
}
81
+
82
+
switch ("${{ inputs.source }}") {
83
+
"swift.org" {
84
+
if (-not $SwiftVersion) {
85
+
Write-Host "::error::swift-version is required when using swift.org source"
86
+
exit 1
87
+
}
88
+
89
+
if (-not $SwiftBuild) {
90
+
Write-Host "::error::swift-build is required when using swift.org source"
91
+
exit 1
92
+
}
93
+
}
94
+
95
+
"custom" {
96
+
if (-not "${{ inputs.github-repo }}") {
97
+
Write-Host "::error::github-repo is required when using custom source"
98
+
exit 1
99
+
}
100
+
101
+
if (-not "${{ inputs.release-tag-name }}") {
102
+
Write-Host "::error::release-tag-name is required when using custom source"
103
+
exit 1
104
+
}
105
+
106
+
if (-not "${{ inputs.release-asset-name }}") {
107
+
Write-Host "::error::release-asset-name is required when using custom source"
108
+
exit 1
109
+
}
110
+
}
111
+
}
112
+
113
+
# Export resolved values for use in subsequent steps.
0 commit comments