@@ -18,6 +18,10 @@ inputs:
18
18
description : ' The version of the Swift toolchain to use'
19
19
required : true
20
20
default : ' latest'
21
+ swift-branch :
22
+ description : ' The branch of the Swift toolchain to use'
23
+ required : true
24
+ default : ' '
21
25
package-path :
22
26
description : ' The folder where the swift package is checked out'
23
27
required : true
@@ -103,17 +107,41 @@ runs:
103
107
exit 1
104
108
fi
105
109
110
+ # when the swift-version contains a dash, that means we want to use a development toolchain
111
+ # e.g., "6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a" will result in using the following SDK and host toolchain:
112
+ # https://github.com/skiptools/swift-android-toolchain/releases/download/6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a-android-24-0.1.artifactbundle.tar.gz.zip
113
+ # https://download.swift.org/swift-6.1-branch/ubuntu2404/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-07-a-ubuntu24.04.tar.gz
114
+
115
+ #swift-branch='swift-6.0.3-release'
116
+ #swift-branch='swift-6.1-branch'
117
+ #swift-branch='development'
106
118
# translate swift-version "latest" into our known latest version
107
119
if [ "${{ inputs.swift-version }}" == 'latest' ]; then
108
120
# fetch the most recent release tag from the toolchain repo
109
121
#LATEST_TAG=$(curl -fsSL -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" --retry 10 --retry-max-time 600 https://api.github.com/repos/skiptools/swift-android-toolchain/releases/latest | jq -r '.tag_name')
110
122
# disabled because it frequently gives "The requested URL returned error: 403"
111
123
LATEST_TAG="6.0.3"
112
- echo "swift-version =${LATEST_TAG}" >> $GITHUB_OUTPUT
124
+ SWIFT_VERSION =${LATEST_TAG}
113
125
else
114
126
echo "swift-version=${{ inputs.swift-version }}" >> $GITHUB_OUTPUT
115
127
fi
116
128
129
+ echo "swift-version=${SWIFT_VERSION}" >> $GITHUB_OUTPUT
130
+
131
+ if [ "${{ inputs.swift-branch }}" == '' ]; then
132
+ echo "swift-branch=swift-${SWIFT_VERSION}-release" >> $GITHUB_OUTPUT
133
+ else
134
+ echo "swift-branch=${{ inputs.swift-branch }}" >> $GITHUB_OUTPUT
135
+ fi
136
+
137
+ # the swift-id is the basename of the host toolchain download
138
+ SWIFT_VERSION_ID="swift-${SWIFT_VERSION}"
139
+ if [[ ${SWIFT_VERSION} != *-* ]]; then
140
+ # a bare version name like "6.0.3" will have "-RELEASE" tacked on to the end
141
+ SWIFT_VERSION_ID="${SWIFT_VERSION_ID}-RELEASE"
142
+ fi
143
+ echo "swift-id=${SWIFT_VERSION_ID}" >> $GITHUB_OUTPUT
144
+
117
145
- name : Cache Swift ${{ steps.setup.outputs.swift-version }} Host Toolchain
118
146
uses : actions/cache@v4
119
147
id : cache-swift
@@ -125,13 +153,13 @@ runs:
125
153
if : steps.cache-swift.outputs.cache-hit != 'true'
126
154
shell : bash
127
155
run : |
128
- SWIFT_ID="swift-${{ steps.setup.outputs.swift-version }}-RELEASE"
129
156
mkdir -p ~/swift-download
130
157
cd ~/swift-download
158
+ BASE_URL="https://download.swift.org/${{ steps.setup.outputs.swift-branch }}"
131
159
if [ ${RUNNER_OS} == 'Linux' ]; then
132
- curl -fsSL --retry 8 --retry-connrefused https://download.swift.org/swift- ${{ steps.setup.outputs.swift-version }}-release /${{ steps.setup.outputs.osid }}/${SWIFT_ID}/${SWIFT_ID }-${{ steps.setup.outputs.osidpair }}.tar.gz --output swift.tar.gz
160
+ curl -fsSL --retry 8 --retry-connrefused ${BASE_URL}/ ${{ steps.setup.outputs.osid }}/${{ steps.setup.outputs.swift-id }}/${{ steps.setup.outputs.swift-id } }-${{ steps.setup.outputs.osidpair }}.tar.gz --output swift.tar.gz
133
161
elif [ ${RUNNER_OS} == 'macOS' ]; then
134
- curl -fsSL --retry 8 --retry-connrefused https://download.swift.org/swift- ${{ steps.setup.outputs.swift-version }}-release/xcode/${SWIFT_ID}/${SWIFT_ID }-osx.pkg --output swift.pkg
162
+ curl -fsSL --retry 8 --retry-connrefused ${BASE_URL}/xcode/ ${{ steps.setup.outputs.swift-id }}/${{ steps.setup.outputs.swift-id } }-osx.pkg --output swift.pkg
135
163
else
136
164
echo "::error::Unsupported platform: ${RUNNER_OS}"
137
165
exit 1
@@ -141,14 +169,13 @@ runs:
141
169
shell : bash
142
170
run : |
143
171
cd ~/swift-download
144
- SWIFT_ID="swift-${{ steps.setup.outputs.swift-version }}-RELEASE"
145
172
if [ ${RUNNER_OS} == 'Linux' ]; then
146
- mkdir -p ${HOME}/swift/toolchains/$SWIFT_ID
147
- tar -xzf swift.tar.gz -C ${HOME}/swift/toolchains/$SWIFT_ID -- strip 1
148
- SWIFT_INSTALLATION=$HOME/swift/toolchains/$SWIFT_ID /usr
173
+ mkdir -p ${HOME}/swift/toolchains/${{ steps.setup.outputs.swift-id }}
174
+ tar -xzf swift.tar.gz -C ${HOME}/swift/toolchains/${{ steps.setup.outputs.swift-id }} -- strip 1}
175
+ SWIFT_INSTALLATION=$HOME/swift/toolchains/${{ steps.setup.outputs.swift-id }} /usr
149
176
elif [ ${RUNNER_OS} == 'macOS' ]; then
150
177
/usr/sbin/installer -pkg swift.pkg -target CurrentUserHomeDirectory
151
- SWIFT_INSTALLATION=${HOME}/Library/Developer/Toolchains/${SWIFT_ID }.xctoolchain/usr
178
+ SWIFT_INSTALLATION=${HOME}/Library/Developer/Toolchains/${{ steps.setup.outputs.swift-id } }.xctoolchain/usr
152
179
echo "TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw ${SWIFT_INSTALLATION}/Info.plist)" >> $GITHUB_ENV
153
180
else
154
181
echo "::error::Unsupported platform: ${RUNNER_OS}"
@@ -166,11 +193,11 @@ runs:
166
193
SWIFT_SDK_ANROID_API="24"
167
194
echo "SWIFT_SDK_ANROID_API=${SWIFT_SDK_ANROID_API}" >> $GITHUB_ENV
168
195
169
- SWIFT_SDK_ID="swift- ${{ steps.setup.outputs.swift-version }}-RELEASE -android-${SWIFT_SDK_ANROID_API}-0.1"
196
+ SWIFT_SDK_ID="${{ steps.setup.outputs.swift-id }}-android-${SWIFT_SDK_ANROID_API}-0.1"
170
197
echo "SWIFT_SDK_TARGET=${SWIFT_SDK_TARGET}" >> $GITHUB_ENV
171
198
172
199
# variant that identifies the SDK
173
- SWIFT_SDK_ID_SHORT="swift- ${{ steps.setup.outputs.swift-version }}-release -android-${SWIFT_SDK_ANROID_API}-sdk"
200
+ SWIFT_SDK_ID_SHORT="${{ steps.setup.outputs.swift-branch }}-android-${SWIFT_SDK_ANROID_API}-sdk"
174
201
echo "SWIFT_SDK_ID_SHORT=${SWIFT_SDK_ID_SHORT}" >> $GITHUB_ENV
175
202
176
203
SWIFT_SDK_TARGET="${{ steps.setup.outputs.android-sdk-arch }}-unknown-linux-android${SWIFT_SDK_ANROID_API}"
0 commit comments