-
Notifications
You must be signed in to change notification settings - Fork 188
ci(swift): Swift CI/CD only – auto-tag, build-release, release, Packa… #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
f84e929
e728114
30c23a6
00c1eba
cb07423
9dfb4ec
37ad693
cfe813b
fcbe222
1328ad3
7f21179
98336e9
9127453
459abcf
2139b85
6d83bcb
892c82a
0c5f063
b1fa241
3f4934d
93ddf5e
129a799
c884700
124fa8b
7055a3d
7c38b94
0d4c26b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # ============================================================================= | ||
| # Swift SDK Auto-Tag (Phase 1 CI/CD) | ||
| # | ||
| # Merges to main automatically create a new git tag swift-vX.Y.Z to mark | ||
| # official Swift SDK release points. Full build/publish automation will be | ||
| # added later. No builds, no publishing, no macOS runners in this phase. | ||
| # | ||
| # PR description: Merges to main auto-create swift-vX.Y.Z tags to mark | ||
| # official Swift SDK release points. Full build/publish automation will be | ||
| # added later. | ||
| # ============================================================================= | ||
|
|
||
| name: Swift SDK Auto-Tag | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| tag: | ||
| name: Create Swift SDK Tag | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Compute Next Tag | ||
| id: next_tag | ||
| run: | | ||
| set -e | ||
| # List swift-v* tags, strip prefix, keep only X.Y.Z (no prerelease) | ||
| LATEST=$(git tag -l 'swift-v*' | sed 's/^swift-v//' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1 || true) | ||
| if [ -z "$LATEST" ]; then | ||
| NEXT="0.1.1" | ||
| else | ||
| MAJOR=$(echo "$LATEST" | cut -d. -f1) | ||
| MINOR=$(echo "$LATEST" | cut -d. -f2) | ||
| PATCH=$(echo "$LATEST" | cut -d. -f3) | ||
| PATCH=$((PATCH + 1)) | ||
| NEXT="$MAJOR.$MINOR.$PATCH" | ||
| fi | ||
| NEW_TAG="swift-v$NEXT" | ||
| echo "tag=$NEW_TAG" >> "$GITHUB_OUTPUT" | ||
| echo "Computed next tag: $NEW_TAG" | ||
|
Comment on lines
+38
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Auto-tagging always bumps patch; version source of truth is unclear
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/swift-auto-tag.yml
Line: 38:55
Comment:
[P1] Auto-tagging always bumps patch; version source of truth is unclear
`swift-auto-tag.yml` computes the next tag by taking the highest existing `swift-vX.Y.Z` and incrementing PATCH. That means every merge to `main` is a “patch release”, regardless of what actually changed, and it can diverge from the Swift SDK’s own versioning (e.g., `Package.swift`’s `sdkVersion`). If releases should follow an explicit version file or changelog, derive the tag from that instead of auto-incrementing.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| - name: Skip If Tag Exists | ||
| id: skip | ||
| run: | | ||
| NEW_TAG="${{ steps.next_tag.outputs.tag }}" | ||
| if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then | ||
| echo "Tag $NEW_TAG already exists, skipping (idempotent rerun)" | ||
| echo "skip=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "skip=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Create and Push Tag | ||
| if: steps.skip.outputs.skip != 'true' | ||
| run: | | ||
| NEW_TAG="${{ steps.next_tag.outputs.tag }}" | ||
| git tag -a "$NEW_TAG" -m "Swift SDK Release $NEW_TAG" | ||
| git push origin "$NEW_TAG" | ||
| echo "Pushed tag: $NEW_TAG" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| # ============================================================================= | ||
| # Swift SDK Build & Release (Phase 2 CI/CD) | ||
| # | ||
| # When a swift-v* tag is pushed (from Phase 1), build native XCFrameworks via | ||
| # build-ios.sh and the Swift SDK via build-swift.sh on macOS, compute SHA256 | ||
| # checksums of the ZIPs, update Package.swift with those checksums and | ||
| # sdkVersion, commit and push to main, move the tag to that commit, then | ||
| # create a GitHub Release and attach the built artifacts. SPM consumers then | ||
| # resolve the tag and get correct checksums for the release assets. | ||
| # | ||
| # Phase 1 decides when (tag on merge to main). Phase 2 performs what | ||
| # (build + package + release assets + checksum update). | ||
| # | ||
| # PR description: Swift SDK builds are automated on swift-v* tag push: | ||
| # build-ios.sh and build-swift.sh run on macOS, and the resulting XCFrameworks | ||
| # are attached to the GitHub Release. No CocoaPods/App Store; no cross-SDK | ||
| # orchestration. | ||
| # ============================================================================= | ||
|
|
||
| name: Swift SDK Build & Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'swift-v*' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| env: | ||
| COMMONS_DIR: sdk/runanywhere-commons | ||
| SWIFT_SDK_DIR: sdk/runanywhere-swift | ||
|
|
||
| jobs: | ||
| build-and-release: | ||
| name: Build & Release Swift SDK | ||
| runs-on: macos-14 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
|
Comment on lines
+39
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P0] This workflow deletes and recreates tags ( Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/swift-sdk-build-release.yml
Line: 39:42
Comment:
[P0] `actions/checkout` should fetch tags/complete history for retagging
This workflow deletes and recreates tags (`git push origin ":refs/tags/${TAG}"` then `git tag -f ...`), but `actions/checkout@v4` defaults to `fetch-depth: 1` and may not fetch tags; in that case the local repo may not have the tag ref you’re trying to move/overwrite and can behave unexpectedly (or require extra fetch). Setting `with: fetch-depth: 0` (and/or `fetch-tags: true`) makes tag operations deterministic.
How can I resolve this? If you propose a fix, please make it concise. |
||
| - name: Determine Version | ||
| id: version | ||
| run: | | ||
| TAG="${GITHUB_REF#refs/tags/}" | ||
| VERSION="${TAG#swift-v}" | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | ||
| echo "Building Swift SDK $TAG (version $VERSION)" | ||
|
|
||
| - name: Build Native XCFrameworks | ||
| run: | | ||
| ./${COMMONS_DIR}/scripts/build-ios.sh --clean | ||
| echo "XCFrameworks:" | ||
| ls -la ${COMMONS_DIR}/dist/*.xcframework 2>/dev/null || true | ||
|
Comment on lines
+53
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P0]
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/swift-sdk-build-release.yml
Line: 52:56
Comment:
[P0] `ls ${COMMONS_DIR}/dist/*.xcframework` won’t list directories
`*.xcframework` are directories, so `ls -la ${COMMONS_DIR}/dist/*.xcframework` typically won’t match and will always fall into the `|| true` branch. This can hide whether the build actually produced frameworks. Use a directory glob (or `ls -la ${COMMONS_DIR}/dist/*.xcframework/`) so it reports correctly.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| - name: Build Swift SDK | ||
| run: | | ||
| ./${SWIFT_SDK_DIR}/scripts/build-swift.sh --local --build-commons --release | ||
| echo "Swift build complete" | ||
|
|
||
| - name: Prepare Release Assets | ||
| id: assets | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| COMMONS_DIST="${COMMONS_DIR}/dist" | ||
| mkdir -p release-assets | ||
| for name in RACommons RABackendLLAMACPP RABackendONNX; do | ||
| if [ -d "${COMMONS_DIST}/${name}.xcframework" ]; then | ||
| zip_name="${name}-ios-v${VERSION}.zip" | ||
| (cd "${COMMONS_DIST}" && zip -r "../../../../release-assets/${zip_name}" "${name}.xcframework") | ||
| echo "Created release-assets/${zip_name}" | ||
| fi | ||
| done | ||
| echo "assets_dir=release-assets" >> "$GITHUB_OUTPUT" | ||
| ls -la release-assets/ | ||
|
Comment on lines
65
to
79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P0] Release asset zip path likely incorrect (too many Inside Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/swift-sdk-build-release.yml
Line: 63:77
Comment:
[P0] Release asset zip path likely incorrect (too many `../`)
Inside `Prepare Release Assets`, you `cd "${COMMONS_DIST}"` (which is `sdk/runanywhere-commons/dist`) and then write to `../../../../release-assets/...`. From `sdk/runanywhere-commons/dist`, `../../../` reaches repo root; `../../../../` goes one level above the repo, so the zip may be created outside the workspace (or fail). This will break subsequent checksum and release steps.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| - name: Compute Checksums | ||
| id: checksums | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| COMMONS_CHECKSUM=$(shasum -a 256 "release-assets/RACommons-ios-v${VERSION}.zip" | cut -d ' ' -f 1) | ||
| LLAMACPP_CHECKSUM=$(shasum -a 256 "release-assets/RABackendLLAMACPP-ios-v${VERSION}.zip" | cut -d ' ' -f 1) | ||
| ONNX_CHECKSUM=$(shasum -a 256 "release-assets/RABackendONNX-ios-v${VERSION}.zip" | cut -d ' ' -f 1) | ||
| echo "commons=$COMMONS_CHECKSUM" >> "$GITHUB_OUTPUT" | ||
| echo "llamacpp=$LLAMACPP_CHECKSUM" >> "$GITHUB_OUTPUT" | ||
| echo "onnx=$ONNX_CHECKSUM" >> "$GITHUB_OUTPUT" | ||
| echo "RACommons: $COMMONS_CHECKSUM" | ||
| echo "RABackendLLAMACPP: $LLAMACPP_CHECKSUM" | ||
| echo "RABackendONNX: $ONNX_CHECKSUM" | ||
|
Comment on lines
+81
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P0] Checksums step assumes all zips exist, but asset creation is conditional
Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/swift-sdk-build-release.yml
Line: 79:91
Comment:
[P0] Checksums step assumes all zips exist, but asset creation is conditional
`Prepare Release Assets` only zips a framework if the directory exists, but `Compute Checksums` unconditionally runs `shasum` on all three zip files. If any framework wasn’t produced, the workflow will fail here with “No such file”. Either fail earlier when a framework is missing or make checksum generation conditional on what was actually built.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| - name: Update Package.swift Checksums and Version | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| COMMONS_CHECKSUM="${{ steps.checksums.outputs.commons }}" | ||
| LLAMACPP_CHECKSUM="${{ steps.checksums.outputs.llamacpp }}" | ||
| ONNX_CHECKSUM="${{ steps.checksums.outputs.onnx }}" | ||
| # Ensure production mode for release (remote binaries) | ||
| sed -i '' 's/let useLocalBinaries = true/let useLocalBinaries = false/' Package.swift | ||
| # Update sdkVersion | ||
| sed -i '' 's/let sdkVersion = "[^"]*"/let sdkVersion = "'"$VERSION"'"/' Package.swift | ||
| # Update the three binary target checksums (range: url line through checksum line) | ||
| sed -i '' '/RACommons-ios-v.*zip/,/checksum:/ s/checksum: "[^"]*"/checksum: "'"$COMMONS_CHECKSUM"'"/' Package.swift | ||
| sed -i '' '/RABackendLLAMACPP-ios-v.*zip/,/checksum:/ s/checksum: "[^"]*"/checksum: "'"$LLAMACPP_CHECKSUM"'"/' Package.swift | ||
| sed -i '' '/RABackendONNX-ios-v.*zip/,/checksum:/ s/checksum: "[^"]*"/checksum: "'"$ONNX_CHECKSUM"'"/' Package.swift | ||
| echo "Updated Package.swift sdkVersion and checksums" | ||
| grep -A1 "RACommons-ios" Package.swift | head -4 | ||
|
|
||
| - name: Commit and Push Package.swift Update | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add Package.swift | ||
| if git diff --staged --quiet; then | ||
| echo "No Package.swift changes to commit" | ||
| else | ||
| git commit -m "chore(swift): update Package.swift checksums for swift-v${{ steps.version.outputs.version }}" | ||
| git push origin HEAD:main | ||
| fi | ||
|
||
|
|
||
| - name: Update Tag to Commit with Checksums | ||
| run: | | ||
| TAG="${{ steps.version.outputs.tag }}" | ||
| # Delete remote tag so we can move it to the new commit | ||
| git push origin ":refs/tags/${TAG}" || true | ||
| # Tag current commit (with Package.swift update) | ||
| git tag -f "${TAG}" -m "Swift SDK Release ${TAG}" | ||
| git push origin "${TAG}" | ||
| echo "Tag ${TAG} updated to point to commit with correct checksums" | ||
|
|
||
| - name: Create Semver Tag for SPM | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| # SPM resolves versions from semver tags (e.g. 0.1.2 or v0.1.2) | ||
| # Create tag ${VERSION} on same commit so consumers can use from: "X.Y.Z" | ||
| git push origin ":refs/tags/${VERSION}" 2>/dev/null || true | ||
| git tag -f "${VERSION}" -m "Swift SDK v${VERSION}" | ||
| git push origin "${VERSION}" | ||
| echo "Semver tag ${VERSION} created for SPM resolution" | ||
|
||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.version.outputs.tag }} | ||
| name: RunAnywhere Swift SDK v${{ steps.version.outputs.version }} | ||
| body: | | ||
| ## RunAnywhere Swift SDK v${{ steps.version.outputs.version }} | ||
|
|
||
| Privacy-first, on-device AI SDK for iOS and macOS. Built automatically on swift-v* tag push (Phase 2 CI). | ||
|
|
||
| ### Installation | ||
|
|
||
| **Swift Package Manager:** | ||
| ```swift | ||
| dependencies: [ | ||
| .package( | ||
| url: "https://github.com/RunanywhereAI/runanywhere-sdks", | ||
| from: "${{ steps.version.outputs.version }}" | ||
| ) | ||
| ] | ||
| ``` | ||
|
|
||
| Then add the products you need: | ||
| ```swift | ||
| .target( | ||
| name: "YourApp", | ||
| dependencies: [ | ||
| .product(name: "RunAnywhere", package: "runanywhere-sdks"), | ||
| .product(name: "LlamaCPPRuntime", package: "runanywhere-sdks"), | ||
| .product(name: "ONNXRuntime", package: "runanywhere-sdks"), | ||
| ] | ||
| ) | ||
| ``` | ||
|
|
||
| ### Features | ||
| - **LLM**: On-device text generation via llama.cpp | ||
| - **STT**: Speech-to-text via Sherpa-ONNX Whisper | ||
| - **TTS**: Text-to-speech via Sherpa-ONNX Piper | ||
| - **VAD**: Voice activity detection | ||
| - **Privacy**: All processing happens on-device | ||
|
|
||
| ### Requirements | ||
| - iOS 13.0+ / macOS 10.15+ | ||
| - Swift 5.9+ | ||
| - Xcode 15.0+ | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Documentation | ||
| [Swift SDK README](https://github.com/RunanywhereAI/runanywhere-sdks/tree/main/sdk/runanywhere-swift) | ||
|
|
||
| --- | ||
| Built from runanywhere-sdks @ ${{ github.sha }} | ||
| files: release-assets/*.zip | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Broad trigger: tags on every push to
mainThis workflow triggers on any push to
main(including merges, reverts, and automated commits from other workflows). If Phase 2 commits tomain, that commit will also trigger Phase 1 and create another tag unless you add a guard (e.g., skip when actor isgithub-actions[bot]or when commit message matches the checksum update). Otherwise you can end up in a tag churn/feedback loop.Prompt To Fix With AI