Skip to content

Commit 3c2925b

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Automate SwiftPM updates. (#6836)
Summary: Let's make the versioning daily and create a new dedicated branch with swiftpm packages for it, so that the clients can pin themselves to a specific version and never run into checksum mismatch issues when we overwrite the binaries on S3. Differential Revision: D65908021
1 parent 31dbfc9 commit 3c2925b

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/apple.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ concurrency:
2525
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
2626
cancel-in-progress: true
2727

28+
env:
29+
VERSION: "0.4.0-$(date +%Y%m%d)"
30+
2831
jobs:
2932
build-demo-ios:
3033
name: build-demo-ios
@@ -122,7 +125,7 @@ jobs:
122125
timeout: 90
123126
script: |
124127
BUILD_TOOL=cmake
125-
VERSION="latest"
128+
VERSION="${{ env.VERSION }}"
126129
FRAMEWORKS=(
127130
"executorch"
128131
"backend_coreml"
@@ -203,6 +206,7 @@ jobs:
203206
shell: bash
204207
run: |
205208
set -eux
209+
VERSION="${{ env.VERSION }}"
206210
207211
pip install awscli==1.32.18
208212
@@ -211,11 +215,45 @@ jobs:
211215
AWS_CMD="aws s3 cp"
212216
fi
213217
218+
CHECKSUMS=()
214219
for FILENAME in "${RUNNER_TEMP}"/frameworks-ios/*.zip; do
215220
[ -e "${FILENAME}" ] || continue
216-
shasum -a 256 "${FILENAME}"
221+
FRAMEWORK_NAME=$(basename "${FILENAME}" | sed "s/-${VERSION}.zip//")
222+
CHECKSUM=$(shasum -a 256 "${FILENAME}" | cut -d ' ' -f1)
217223
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
224+
CHECKSUMS["${FRAMEWORK_NAME}"]="${CHECKSUM}"
218225
done
226+
echo "${CHECKSUMS[@]}" > checksums.txt
227+
228+
- name: Update SwiftPM
229+
shell: bash
230+
run: |
231+
set -eux
232+
VERSION="${{ env.VERSION }}"
233+
234+
git clone https://github.com/pytorch/executorch.git --branch swiftpm --depth 1
235+
cd executorch
236+
if git show-ref --verify --quiet refs/heads/swiftpm-${VERSION}; then
237+
git checkout "swiftpm-${VERSION}"
238+
else
239+
git checkout -b "swiftpm-${VERSION}"
240+
fi
241+
242+
cp -f Package.swift.template Package.swift
243+
sed -i '' "s/__VERSION__/${VERSION}/g" Package.swift
244+
245+
while read -r FRAMEWORK CHECKSUM; do
246+
sed -i '' "s/__SHA256_${FRAMEWORK}__/${CHECKSUM}/g" Package.swift
247+
done < ../checksums.txt
248+
249+
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
250+
git add Package.swift
251+
git commit -m "${VERSION}"
252+
git push origin "swiftpm-${VERSION}"
253+
else
254+
echo "Draft Package.swift:"
255+
cat Package.swift
256+
fi
219257
220258
build-benchmark-app:
221259
name: build-benchmark-app

0 commit comments

Comments
 (0)