Skip to content
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

iOS向けXCFrameworkを追加する #19

Merged
merged 12 commits into from
May 19, 2023
63 changes: 62 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,70 @@ jobs:
tar cfz "${{ env.RELEASE_NAME }}.tgz" "${{ env.RELEASE_NAME }}/"

- name: Upload to Release
if: env.RELEASE == 'true'
if: env.RELEASE == 'true' && !contains(matrix.artifact_name, 'ios')
PickledChair marked this conversation as resolved.
Show resolved Hide resolved
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 }}.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"

PickledChair marked this conversation as resolved.
Show resolved Hide resolved
- 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