From 55f5d890665d6853852bf27192deef8d424e578b Mon Sep 17 00:00:00 2001 From: Hyoda Kazuaki Date: Sat, 20 May 2023 03:14:37 +0900 Subject: [PATCH] =?UTF-8?q?iOS=E5=90=91=E3=81=91XCFramework=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=20(#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) 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