diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a507228..656663e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -201,3 +201,64 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ env.ONNXRUNTIME_VERSION }} # ==> github.event.release.tag_name file: ${{ env.RELEASE_NAME }}.tgz + + build-xcframework: + needs: build-onnxruntime + runs-on: macos-12 + steps: + - name: Generate RELEASE_NAME and ONNXRUNTIME_BASENAME + run: | + echo "RELEASE_NAME=onnxruntime-xcframework-${{ env.ONNXRUNTIME_VERSION }}" >> $GITHUB_ENV + echo "ONNXRUNTIME_BASENAME=libonnxruntime.${{ env.ONNXRUNTIME_VERSION }}.dylib" >> "$GITHUB_ENV" + + - uses: actions/download-artifact@v2 + with: + name: onnxruntime-ios-arm64 + path: artifact/onnxruntime-aarch64-apple-ios + + - uses: actions/download-artifact@v2 + with: + name: onnxruntime-ios-sim-arm64 + path: artifact/onnxruntime-aarch64-apple-ios-sim + + - uses: actions/download-artifact@v2 + with: + name: onnxruntime-ios-sim-x86_64 + path: artifact/onnxruntime-x86_64-apple-ios + + - name: Remove no version notation dylib + shell: bash + run: | + rm -f artifact/onnxruntime-x86_64-apple-ios/lib/*onnxruntime.dylib + rm -f artifact/onnxruntime-aarch64-apple-ios-sim/lib/*onnxruntime.dylib + rm -f artifact/onnxruntime-aarch64-apple-ios/lib/*onnxruntime.dylib + + - name: Create fat binary + shell: bash + run: | + mkdir -p "artifact/onnxruntime-sim" + lipo -create "artifact/onnxruntime-x86_64-apple-ios/lib/${{ env.ONNXRUNTIME_BASENAME }}" "artifact/onnxruntime-aarch64-apple-ios-sim/lib/${{ env.ONNXRUNTIME_BASENAME }}" -output "artifact/onnxruntime-sim/${{ env.ONNXRUNTIME_BASENAME }}" + + - name: Create XCFramework + shell: bash + run: | + mkdir -p "artifact/${{ env.ONNXRUNTIME_BASENAME }}" + xcodebuild -create-xcframework \ + -library "artifact/onnxruntime-sim/${{ env.ONNXRUNTIME_BASENAME }}" \ + -library "artifact/onnxruntime-aarch64-apple-ios/lib/${{ env.ONNXRUNTIME_BASENAME }}" \ + -output "artifact/${{ env.ONNXRUNTIME_BASENAME }}/onnxruntime.xcframework" + + - name: Archive artifact + shell: bash + run: | + cd artifact/${{ env.ONNXRUNTIME_BASENAME }} + 7z a "../../${{ env.RELEASE_NAME }}.zip" "onnxruntime.xcframework" + + - name: Upload to Release + if: env.RELEASE == 'true' + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.ONNXRUNTIME_VERSION }} # ==> github.event.release.tag_name + file: ${{ env.RELEASE_NAME }}.zip + \ No newline at end of file