|
| 1 | +name: Build and Release XCFrameworks |
| 2 | + |
| 3 | +# ============================================================================= |
| 4 | +# This workflow builds modular XCFrameworks for iOS/macOS: |
| 5 | +# - RACommons.xcframework (core commons library) |
| 6 | +# - RABackendLlamaCPP.xcframework (LLM backend) |
| 7 | +# - RABackendONNX.xcframework (STT/TTS/VAD backend) |
| 8 | +# |
| 9 | +# It downloads runanywhere-core source from the public runanywhere-binaries |
| 10 | +# repository, builds the XCFrameworks, and publishes them. |
| 11 | +# |
| 12 | +# Trigger: |
| 13 | +# - Tag push: commons-v* |
| 14 | +# - Manual workflow_dispatch |
| 15 | +# |
| 16 | +# ============================================================================= |
| 17 | + |
| 18 | +on: |
| 19 | + push: |
| 20 | + tags: |
| 21 | + - 'commons-v*' |
| 22 | + workflow_dispatch: |
| 23 | + inputs: |
| 24 | + version: |
| 25 | + description: 'Version to release (e.g., 2.0.0)' |
| 26 | + required: true |
| 27 | + type: string |
| 28 | + core_version: |
| 29 | + description: 'runanywhere-core version to use (leave empty for latest)' |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + dry_run: |
| 33 | + description: 'Dry run (build only, do not publish)' |
| 34 | + required: false |
| 35 | + default: false |
| 36 | + type: boolean |
| 37 | + |
| 38 | +env: |
| 39 | + # Public binaries repository for publishing XCFrameworks |
| 40 | + PUBLIC_REPO_OWNER: 'RunanywhereAI' |
| 41 | + PUBLIC_REPO_NAME: 'runanywhere-binaries' |
| 42 | + # Working directory for commons |
| 43 | + COMMONS_DIR: sdk/runanywhere-commons |
| 44 | + |
| 45 | +jobs: |
| 46 | + # =========================================================================== |
| 47 | + # Build iOS XCFrameworks |
| 48 | + # =========================================================================== |
| 49 | + build-ios: |
| 50 | + name: Build iOS XCFrameworks |
| 51 | + runs-on: macos-14 |
| 52 | + outputs: |
| 53 | + version: ${{ steps.version.outputs.version }} |
| 54 | + core_version: ${{ steps.core.outputs.core_version }} |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Determine Version |
| 61 | + id: version |
| 62 | + run: | |
| 63 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 64 | + VERSION="${{ github.event.inputs.version }}" |
| 65 | + else |
| 66 | + VERSION="${GITHUB_REF#refs/tags/commons-v}" |
| 67 | + fi |
| 68 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 69 | + echo "Building version: $VERSION" |
| 70 | +
|
| 71 | + - name: Setup Xcode |
| 72 | + uses: maxim-lobanov/setup-xcode@v1 |
| 73 | + with: |
| 74 | + xcode-version: '15.4' |
| 75 | + |
| 76 | + - name: Install Dependencies |
| 77 | + run: brew install cmake ninja |
| 78 | + |
| 79 | + - name: Download runanywhere-core Source |
| 80 | + id: core |
| 81 | + working-directory: ${{ env.COMMONS_DIR }} |
| 82 | + run: | |
| 83 | + chmod +x scripts/download-core.sh |
| 84 | +
|
| 85 | + # Determine core version |
| 86 | + if [ -n "${{ github.event.inputs.core_version }}" ]; then |
| 87 | + CORE_VERSION="${{ github.event.inputs.core_version }}" |
| 88 | + else |
| 89 | + # Fetch latest from runanywhere-binaries |
| 90 | + CORE_VERSION=$(curl -sL "https://raw.githubusercontent.com/${{ env.PUBLIC_REPO_OWNER }}/${{ env.PUBLIC_REPO_NAME }}/main/LATEST_CORE_VERSION" || echo "") |
| 91 | + if [ -z "$CORE_VERSION" ]; then |
| 92 | + echo "Failed to fetch latest core version, using 'latest'" |
| 93 | + CORE_VERSION="latest" |
| 94 | + fi |
| 95 | + fi |
| 96 | +
|
| 97 | + echo "Using runanywhere-core version: $CORE_VERSION" |
| 98 | + echo "core_version=$CORE_VERSION" >> $GITHUB_OUTPUT |
| 99 | +
|
| 100 | + # Download core source and dependencies |
| 101 | + RUNANYWHERE_CORE_VERSION="$CORE_VERSION" ./scripts/download-core.sh |
| 102 | +
|
| 103 | + - name: Verify Core Downloaded |
| 104 | + working-directory: ${{ env.COMMONS_DIR }} |
| 105 | + run: | |
| 106 | + if [ ! -d "third_party/runanywhere-core" ]; then |
| 107 | + echo "ERROR: runanywhere-core not downloaded" |
| 108 | + exit 1 |
| 109 | + fi |
| 110 | + echo "Core version: $(cat third_party/runanywhere-core/DOWNLOADED_VERSION 2>/dev/null || echo 'unknown')" |
| 111 | + ls -la third_party/runanywhere-core/ |
| 112 | +
|
| 113 | + - name: Build iOS XCFrameworks |
| 114 | + working-directory: ${{ env.COMMONS_DIR }} |
| 115 | + run: | |
| 116 | + chmod +x scripts/build-ios.sh |
| 117 | + ./scripts/build-ios.sh |
| 118 | +
|
| 119 | + - name: Package Release |
| 120 | + working-directory: ${{ env.COMMONS_DIR }} |
| 121 | + run: | |
| 122 | + chmod +x scripts/package-release.sh |
| 123 | + ./scripts/package-release.sh ${{ steps.version.outputs.version }} |
| 124 | +
|
| 125 | + - name: List Artifacts |
| 126 | + working-directory: ${{ env.COMMONS_DIR }} |
| 127 | + run: | |
| 128 | + echo "=== Build Artifacts ===" |
| 129 | + ls -la dist/ |
| 130 | + echo "" |
| 131 | + echo "=== XCFramework Sizes ===" |
| 132 | + for xcf in dist/*.xcframework; do |
| 133 | + if [ -d "$xcf" ]; then |
| 134 | + size=$(du -sh "$xcf" | cut -f1) |
| 135 | + echo " $(basename "$xcf"): $size" |
| 136 | + fi |
| 137 | + done |
| 138 | +
|
| 139 | + - name: Upload Artifacts |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: xcframeworks-${{ steps.version.outputs.version }} |
| 143 | + path: | |
| 144 | + ${{ env.COMMONS_DIR }}/dist/*.xcframework.zip |
| 145 | + ${{ env.COMMONS_DIR }}/dist/*.zip |
| 146 | + ${{ env.COMMONS_DIR }}/dist/*.sha256 |
| 147 | + ${{ env.COMMONS_DIR }}/dist/MANIFEST.md |
| 148 | + retention-days: 30 |
| 149 | + |
| 150 | + # =========================================================================== |
| 151 | + # Publish to runanywhere-binaries |
| 152 | + # =========================================================================== |
| 153 | + publish: |
| 154 | + name: Publish to runanywhere-binaries |
| 155 | + needs: build-ios |
| 156 | + if: github.event.inputs.dry_run != 'true' |
| 157 | + runs-on: ubuntu-latest |
| 158 | + permissions: |
| 159 | + contents: write |
| 160 | + |
| 161 | + steps: |
| 162 | + - name: Download Artifacts |
| 163 | + uses: actions/download-artifact@v4 |
| 164 | + with: |
| 165 | + name: xcframeworks-${{ needs.build-ios.outputs.version }} |
| 166 | + path: dist |
| 167 | + |
| 168 | + - name: List Downloaded Artifacts |
| 169 | + run: | |
| 170 | + echo "=== Downloaded Artifacts ===" |
| 171 | + ls -laR dist/ |
| 172 | +
|
| 173 | + - name: Checkout Public Binaries Repo |
| 174 | + uses: actions/checkout@v4 |
| 175 | + with: |
| 176 | + repository: ${{ env.PUBLIC_REPO_OWNER }}/${{ env.PUBLIC_REPO_NAME }} |
| 177 | + token: ${{ secrets.BINARY_REPO_PAT }} |
| 178 | + path: public-repo |
| 179 | + fetch-depth: 0 |
| 180 | + |
| 181 | + - name: Update Public Repository |
| 182 | + run: | |
| 183 | + VERSION="${{ needs.build-ios.outputs.version }}" |
| 184 | + CORE_VERSION="${{ needs.build-ios.outputs.core_version }}" |
| 185 | +
|
| 186 | + cd public-repo |
| 187 | +
|
| 188 | + # Create releases directory |
| 189 | + mkdir -p releases/commons-v${VERSION} |
| 190 | +
|
| 191 | + # Copy all XCFramework ZIPs (handle nested directory from artifact download) |
| 192 | + find ../dist -name "*.zip" -exec cp {} releases/commons-v${VERSION}/ \; 2>/dev/null || true |
| 193 | + find ../dist -name "*.sha256" -exec cp {} releases/commons-v${VERSION}/ \; 2>/dev/null || true |
| 194 | +
|
| 195 | + # Update version files |
| 196 | + echo "${VERSION}" > LATEST_COMMONS_VERSION |
| 197 | +
|
| 198 | + # Git operations |
| 199 | + git config user.name "GitHub Actions Bot" |
| 200 | + git config user.email "actions@github.com" |
| 201 | +
|
| 202 | + git add -A |
| 203 | + git commit -m "Release runanywhere-commons v${VERSION} |
| 204 | +
|
| 205 | + Built with runanywhere-core: ${CORE_VERSION} |
| 206 | +
|
| 207 | + XCFrameworks: |
| 208 | + $(ls -1 releases/commons-v${VERSION}/*.zip 2>/dev/null | xargs -I {} basename {} || echo 'None') |
| 209 | + " || echo "No changes to commit" |
| 210 | +
|
| 211 | + - name: Create Git Tag |
| 212 | + run: | |
| 213 | + VERSION="${{ needs.build-ios.outputs.version }}" |
| 214 | + cd public-repo |
| 215 | + git tag -a "commons-v${VERSION}" -m "runanywhere-commons v${VERSION}" 2>/dev/null || echo "Tag already exists" |
| 216 | +
|
| 217 | + - name: Push to Public Repository |
| 218 | + run: | |
| 219 | + cd public-repo |
| 220 | + git push origin main --tags |
| 221 | + env: |
| 222 | + GITHUB_TOKEN: ${{ secrets.BINARY_REPO_PAT }} |
| 223 | + |
| 224 | + - name: Create GitHub Release |
| 225 | + uses: softprops/action-gh-release@v2 |
| 226 | + with: |
| 227 | + repository: ${{ env.PUBLIC_REPO_OWNER }}/${{ env.PUBLIC_REPO_NAME }} |
| 228 | + tag_name: commons-v${{ needs.build-ios.outputs.version }} |
| 229 | + name: RunAnywhere Commons v${{ needs.build-ios.outputs.version }} |
| 230 | + files: | |
| 231 | + dist/**/*.zip |
| 232 | + dist/**/*.sha256 |
| 233 | + body: | |
| 234 | + ## RunAnywhere Commons v${{ needs.build-ios.outputs.version }} |
| 235 | +
|
| 236 | + Modular XCFrameworks for iOS/macOS. |
| 237 | +
|
| 238 | + ### XCFrameworks |
| 239 | +
|
| 240 | + | Framework | Description | |
| 241 | + |-----------|-------------| |
| 242 | + | `RACommons.xcframework` | Core commons library (service registry, model management) | |
| 243 | + | `RABackendLlamaCPP.xcframework` | LLM backend (llama.cpp + Metal) | |
| 244 | + | `RABackendONNX.xcframework` | STT/TTS/VAD backend (Sherpa-ONNX) | |
| 245 | +
|
| 246 | + ### Swift Package Manager |
| 247 | +
|
| 248 | + Update your `Package.swift`: |
| 249 | +
|
| 250 | + ```swift |
| 251 | + .binaryTarget( |
| 252 | + name: "RACommonsBinary", |
| 253 | + url: "https://github.com/${{ env.PUBLIC_REPO_OWNER }}/${{ env.PUBLIC_REPO_NAME }}/releases/download/commons-v${{ needs.build-ios.outputs.version }}/RACommons-${{ needs.build-ios.outputs.version }}.zip", |
| 254 | + checksum: "..." |
| 255 | + ), |
| 256 | + ``` |
| 257 | +
|
| 258 | + ### Requirements |
| 259 | +
|
| 260 | + - **ONNX Runtime**: `RABackendONNX` requires `onnxruntime.xcframework` (download separately) |
| 261 | + - **Platforms**: iOS 17+, macOS 14+ |
| 262 | +
|
| 263 | + ### Verification |
| 264 | +
|
| 265 | + ```bash |
| 266 | + shasum -a 256 -c *.sha256 |
| 267 | + ``` |
| 268 | +
|
| 269 | + --- |
| 270 | + Built with runanywhere-core: ${{ needs.build-ios.outputs.core_version }} |
| 271 | + draft: false |
| 272 | + prerelease: false |
| 273 | + env: |
| 274 | + GITHUB_TOKEN: ${{ secrets.BINARY_REPO_PAT }} |
0 commit comments