Skip to content

Commit 8b94ebf

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. Reviewed By: GregoryComer Differential Revision: D65908021
1 parent ecdc007 commit 8b94ebf

File tree

1 file changed

+68
-15
lines changed

1 file changed

+68
-15
lines changed

.github/workflows/apple.yml

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@ on:
2020
- extension/benchmark/apple/**
2121
- extension/module/**
2222
workflow_dispatch:
23+
schedule:
24+
- cron: '0 10 * * *' # Runs daily at 2 AM PST
2325

2426
concurrency:
2527
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
2628
cancel-in-progress: true
2729

2830
jobs:
31+
set-version:
32+
runs-on: ubuntu-22.04
33+
outputs:
34+
version: ${{ steps.set_version.outputs.version }}
35+
steps:
36+
- name: Set VERSION variable
37+
id: set_version
38+
shell: bash
39+
run: |
40+
VERSION="0.4.0.$(TZ='PST8PDT' date +%Y%m%d)"
41+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
42+
2943
build-demo-ios:
3044
name: build-demo-ios
3145
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -39,6 +53,8 @@ jobs:
3953
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
4054
upload-artifact: ios-apps
4155
script: |
56+
set -eux
57+
4258
BUILD_TOOL=cmake
4359
4460
.ci/scripts/setup-conda.sh
@@ -57,7 +73,7 @@ jobs:
5773
5874
# Build and test iOS Demo App
5975
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
60-
build/test_ios_ci.sh ${ARTIFACTS_DIR_NAME}
76+
build/test_ios_ci.sh "${ARTIFACTS_DIR_NAME}"
6177
6278
# Upload the test demo app to S3
6379
upload-demo-ios:
@@ -75,6 +91,7 @@ jobs:
7591
shell: bash
7692
working-directory: ${{ runner.temp }}/artifacts/
7793
run: |
94+
set -eux
7895
ls -lah ./
7996
8097
- name: Upload the artifacts to S3
@@ -112,6 +129,7 @@ jobs:
112129

113130
build-frameworks-ios:
114131
name: build-frameworks-ios
132+
needs: set-version
115133
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
116134
with:
117135
runner: macos-latest-xlarge
@@ -121,8 +139,10 @@ jobs:
121139
upload-artifact: executorch-frameworks-ios
122140
timeout: 90
123141
script: |
142+
set -eux
143+
124144
BUILD_TOOL=cmake
125-
VERSION="latest"
145+
VERSION="${{ needs.set-version.outputs.version }}"
126146
FRAMEWORKS=(
127147
"executorch"
128148
"backend_coreml"
@@ -171,38 +191,38 @@ jobs:
171191
172192
upload-frameworks-ios:
173193
runs-on: ubuntu-22.04
174-
needs: build-frameworks-ios
194+
needs: [build-frameworks-ios, set-version]
175195
timeout-minutes: 30
176196
permissions:
177197
id-token: write
178-
contents: read
198+
contents: write
179199
steps:
180200
- uses: actions/checkout@v3
181201
- uses: actions/setup-python@v4
182202
with:
183203
python-version: '3.11'
184204
cache: pip
185-
- name: configure aws credentials
186-
uses: aws-actions/[email protected]
187-
with:
188-
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-ios
189-
aws-region: us-east-1
205+
# - name: configure aws credentials
206+
# uses: aws-actions/[email protected]
207+
# with:
208+
# role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-ios
209+
# aws-region: us-east-1
190210
- name: Download the artifact
191211
uses: actions/download-artifact@v3
192212
with:
193213
# NB: The name here needs to match the upload-artifact name from build-frameworks-ios job
194214
name: executorch-frameworks-ios
195215
path: ${{ runner.temp }}/frameworks-ios/
196216
- name: Only push to S3 when running the workflow manually from main branch
197-
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
217+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}
198218
shell: bash
199219
run: |
200-
set -eux
201220
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
202221
- name: Upload the artifact to ossci-ios S3 bucket
203222
shell: bash
204223
run: |
205224
set -eux
225+
VERSION="${{ needs.set-version.outputs.version }}"
206226
207227
pip install awscli==1.32.18
208228
@@ -212,10 +232,43 @@ jobs:
212232
fi
213233
214234
for FILENAME in "${RUNNER_TEMP}"/frameworks-ios/*.zip; do
215-
[ -e "${FILENAME}" ] || continue
216-
shasum -a 256 "${FILENAME}"
217-
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
235+
FRAMEWORK_NAME=$(basename "${FILENAME}" | sed "s/-${VERSION}.zip//")
236+
CHECKSUM=$(shasum -a 256 "${FILENAME}" | cut -d ' ' -f1)
237+
echo "${FRAMEWORK_NAME} ${CHECKSUM}" >> "${RUNNER_TEMP}/checksums.txt"
218238
done
239+
- name: Update SwiftPM
240+
shell: bash
241+
run: |
242+
set -eux
243+
VERSION="${{ needs.set-version.outputs.version }}"
244+
BRANCH="swiftpm-${VERSION}"
245+
246+
git checkout swiftpm
247+
248+
if git show-ref --verify --quiet refs/heads/${BRANCH}; then
249+
git checkout "${BRANCH}"
250+
else
251+
git checkout -b "${BRANCH}"
252+
fi
253+
254+
[[ -f Package.swift ]] || mv Package.swift.template Package.swift
255+
256+
sed -i "s/__VERSION__/${VERSION}/g" Package.swift
257+
258+
while read -r FRAMEWORK CHECKSUM; do
259+
sed -i "s/__SHA256_${FRAMEWORK}__/${CHECKSUM}/g" Package.swift
260+
done < "${RUNNER_TEMP}/checksums.txt"
261+
262+
# if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
263+
git config --global user.name "PyTorch Bot"
264+
git config --global user.email "[email protected]"
265+
git add Package.swift
266+
git commit -m "${VERSION}"
267+
git push origin "${BRANCH}"
268+
# else
269+
# echo "Draft Package.swift:"
270+
# cat Package.swift
271+
# fi
219272
220273
build-benchmark-app:
221274
name: build-benchmark-app
@@ -281,5 +334,5 @@ jobs:
281334
echo "::group::Build ExecuTorch benchmark app"
282335
mkdir -p extension/benchmark/apple/Benchmark/Models
283336
${CONDA_RUN} --no-capture-output \
284-
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
337+
build/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
285338
echo "::endgroup::"

0 commit comments

Comments
 (0)