From a6fbaa769caee5c5dea0a1b947726d0332849c7f Mon Sep 17 00:00:00 2001 From: Junrou Nishida Date: Sat, 9 Jul 2022 14:27:43 +0900 Subject: [PATCH] ci: build custom package (#647) * ci: build a package * set timeout opts * modify the workflow trigger * export DLLs for protobuf * store LICENSE.md * import MediaPipeUnity.framework * fix options for release --- .github/workflows/package.yml | 220 ++++++++++++++++++ .gitignore | 5 +- .../com.github.homuler.mediapipe/LICENSE.md | 21 ++ .../LICENSE.md.meta | 7 + .../Runtime/Plugins/Protobuf.meta | 8 + .../Plugins/Protobuf/Google.Protobuf.dll.meta | 33 +++ .../Plugins/Protobuf/System.Buffers.dll.meta | 33 +++ .../Plugins/Protobuf/System.Memory.dll.meta | 33 +++ ...m.Runtime.CompilerServices.Unsafe.dll.meta | 33 +++ .../MediaPipeUnity.framework/Info.plist.meta | 7 + .../MediaPipeUnity.meta | 7 + .../com.github.homuler.mediapipe/package.json | 5 +- mediapipe_api/objc/BUILD | 2 +- 13 files changed, 408 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/package.yml create mode 100644 Packages/com.github.homuler.mediapipe/LICENSE.md create mode 100644 Packages/com.github.homuler.mediapipe/LICENSE.md.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/Google.Protobuf.dll.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Buffers.dll.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Memory.dll.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Runtime.CompilerServices.Unsafe.dll.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/Info.plist.meta create mode 100644 Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/MediaPipeUnity.meta diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 000000000..ef0a8c622 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,220 @@ +name: Package +on: + workflow_dispatch: {} + push: + tags: + - v* + schedule: + - cron: 0 12 * * 0,3 +jobs: + linux-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.ref }} + + - name: Build a Docker image + run: | + docker build --no-cache --build-arg UID=$(id -u) -t mediapipe_unity:latest . -f docker/linux/x86_64/Dockerfile.ubuntu + + - name: Build + run: | + docker run \ + --mount type=bind,src=$PWD/Packages,dst=/home/mediapipe/Packages \ + --mount type=bind,src=$PWD/Assets,dst=/home/mediapipe/Assets \ + mediapipe_unity:latest \ + python build.py build --bazel_build_opts "--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0" --desktop gpu --opencv cmake -vv + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: base-package + path: . + + android-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.ref }} + + - name: Build a Docker image + run: | + docker build --no-cache --build-arg UID=$(id -u) -t mediapipe_unity:latest . -f docker/linux/x86_64/Dockerfile.ubuntu + + - name: Build + run: | + docker run \ + --mount type=bind,src=$PWD/Packages,dst=/home/mediapipe/Packages \ + --mount type=bind,src=$PWD/Assets,dst=/home/mediapipe/Assets \ + mediapipe_unity:latest \ + python build.py build --bazel_build_opts "--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0" --android fat --android_ndk_api_level 21 -vv + + - name: Upload mediapipe_android.aar + uses: actions/upload-artifact@v2 + with: + name: mediapipe_android.aar + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/Android/mediapipe_android.aar + + macos-build: + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + + # Setup Python + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install NumPy + run: pip install --no-cache-dir --user numpy + + - name: Build libmediapipe_c.dylib + run: | + unset ANDROID_NDK_HOME + python build.py build --bazel_build_opts "--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0" --desktop cpu --opencv cmake --macos_universal -vv + + - name: Upload libmediapipe_c.dylib + uses: actions/upload-artifact@v2 + with: + name: libmediapipe_c.dylib + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/libmediapipe_c.dylib + + ios-build: + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + + # Setup Python + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install NumPy + run: pip install --no-cache-dir --user numpy + + - name: Build libmediapipe_c.dylib + run: | + unset ANDROID_NDK_HOME + sed -i -e 's/PLEASE_SET_YOUR_BUNDLE_ID_HERE/com.github.homuler.mediapipe.unity/g' mediapipe_api/objc/BUILD + python build.py build --bazel_build_opts "--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0" --ios arm64 -vv + + - name: Upload MediaPipeUnity.framework + uses: actions/upload-artifact@v2 + with: + name: MediaPipeUnity.framework + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework + + windows-build: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.ref }} + + - name: Build a Docker image + run: | + docker build --no-cache -t mediapipe_unity:latest . -f docker/windows/x86_64/Dockerfile + shell: cmd + + - name: Build + run: | + docker run --cpus=2 --memory=8g ^ + --mount type=bind,src=%CD%\Packages,dst=C:\mediapipe\Packages ^ + --mount type=bind,src=%CD%\Assets,dst=C:\mediapipe\Assets ^ + mediapipe_unity:latest ^ + python build.py build --bazel_build_opts "--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0" --desktop cpu --opencv cmake -vv + shell: cmd + + - name: Upload mediapipe_c.dll + uses: actions/upload-artifact@v2 + with: + name: mediapipe_c.dll + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/mediapipe_c.dll + + package: + runs-on: ubuntu-latest + needs: + - linux-build + - android-build + - macos-build + - ios-build + - windows-build + steps: + - name: Download the base package + uses: actions/download-artifact@v3 + with: + name: base-package + - name: Download mediapipe_android.aar + uses: actions/download-artifact@v3 + with: + name: mediapipe_android.aar + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/Android + - name: Download libmediapipe_c.dylib + uses: actions/download-artifact@v3 + with: + name: libmediapipe_c.dylib + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins + - name: Download MediaPipeUnity.framework + uses: actions/download-artifact@v3 + with: + name: MediaPipeUnity.framework + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework + - name: Download mediapipe_c.dll + uses: actions/download-artifact@v3 + with: + name: mediapipe_c.dll + path: Packages/com.github.homuler.mediapipe/Runtime/Plugins + + - name: Remove unused meta files + run: | + cd Packages/com.github.homuler.mediapipe/Runtime/Plugins + rm libmediapipe_c.bc.meta + rm libopencv_world.*.meta + rm opencv_world*.dll.meta + + - name: Package + run: | + cd Packages/com.github.homuler.mediapipe + npm pack + mv com.github.homuler.mediapipe-*.tgz ../.. + + - name: Upload the built package + uses: actions/upload-artifact@v2 + with: + name: package + path: com.github.homuler.mediapipe-*.tgz + + clean: + runs-on: ubuntu-latest + if: ${{ always() }} + needs: + - package + steps: + - uses: geekyeggo/delete-artifact@v1 + with: + name: base-package + failOnError: false + + - uses: geekyeggo/delete-artifact@v1 + with: + name: mediapipe_android.aar + failOnError: false + + - uses: geekyeggo/delete-artifact@v1 + with: + name: libmediapipe_c.dylib + failOnError: false + + - uses: geekyeggo/delete-artifact@v1 + with: + name: MediaPipeUnity.framework + failOnError: false + + - uses: geekyeggo/delete-artifact@v1 + with: + name: mediapipe_c.dll + failOnError: false diff --git a/.gitignore b/.gitignore index 34668b713..8251252ec 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,8 @@ *.dll *.dylib *.so -*.framework/ +**/*.framework/* +!**/*.framework/*.meta bazel-* @@ -30,5 +31,5 @@ Assets/StreamingAssets* Packages/com.github.homuler.mediapipe/Runtime/Resources/* !Packages/com.github.homuler.mediapipe/Runtime/Resources/*.meta Packages/com.github.homuler.mediapipe/Runtime/Resources/object_detection_3d.bytes.meta -Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf* +Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/*.dll Packages/com.github.homuler.mediapipe/Runtime/Scripts/Protobuf/**/*.cs diff --git a/Packages/com.github.homuler.mediapipe/LICENSE.md b/Packages/com.github.homuler.mediapipe/LICENSE.md new file mode 100644 index 000000000..66d93f02e --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 homuler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Packages/com.github.homuler.mediapipe/LICENSE.md.meta b/Packages/com.github.homuler.mediapipe/LICENSE.md.meta new file mode 100644 index 000000000..9d6248b57 --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/LICENSE.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e728b176561fa96ed8fde03486bbb142 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf.meta new file mode 100644 index 000000000..216369137 --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c1ec978078bc3d4b89f23abdffda8d0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/Google.Protobuf.dll.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/Google.Protobuf.dll.meta new file mode 100644 index 000000000..aff6c3a1e --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/Google.Protobuf.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: d6da87d6a876f25c5802cf8e0df72d3b +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Buffers.dll.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Buffers.dll.meta new file mode 100644 index 000000000..546242021 --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Buffers.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 20fb96b12d894c5a7a8713caecebd3c8 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Memory.dll.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Memory.dll.meta new file mode 100644 index 000000000..968c1227e --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Memory.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 4e19afad160897b59a93cac7cb3360d1 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Runtime.CompilerServices.Unsafe.dll.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Runtime.CompilerServices.Unsafe.dll.meta new file mode 100644 index 000000000..1e07285fe --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 944fd731fc40094858008e9975b5f55b +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 1 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/Info.plist.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/Info.plist.meta new file mode 100644 index 000000000..56546ee88 --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/Info.plist.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f5e4f9f82c5a94f9aad4546b87ee004e +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/MediaPipeUnity.meta b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/MediaPipeUnity.meta new file mode 100644 index 000000000..0f6526367 --- /dev/null +++ b/Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework/MediaPipeUnity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ad6bde42792844b21b9e9f8bbb04cffa +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.github.homuler.mediapipe/package.json b/Packages/com.github.homuler.mediapipe/package.json index c57d7ab07..d3915019e 100644 --- a/Packages/com.github.homuler.mediapipe/package.json +++ b/Packages/com.github.homuler.mediapipe/package.json @@ -14,13 +14,12 @@ "MediaPipe" ], "scripts": { - "copyLicenseFile": "cat $(npm prefix)/../../LICENSE > LICENSE.md", "setupSampleDir": "rm -rf $(npm prefix)/Samples~ && mkdir -p $(npm prefix)/Samples~", "removeStartScene": "rm \"$(npm prefix)/Samples~/Solutions/Scenes/Start Scene.unity\" && rm \"$(npm prefix)/Samples~/Solutions/Scenes/Start Scene.unity.meta\"", "copySolutionSamples": "cp -r $(npm prefix)/../../Assets/MediaPipeUnity/Samples $(npm prefix)/Samples~/Solutions && npm run removeStartScene", "copyTutorial": "cp -r $(npm prefix)/../../Assets/MediaPipeUnity/Tutorial $(npm prefix)/Samples~/Tutorial", - "prepack": "npm run copyLicenseFile && npm run setupSampleDir && npm run copySolutionSamples && npm run copyTutorial", - "postpack": "rm -rf $(npm prefix)/Samples~ && rm $(npm prefix)/LICENSE.md" + "prepack": "npm run setupSampleDir && npm run copySolutionSamples && npm run copyTutorial", + "postpack": "rm -rf $(npm prefix)/Samples~" }, "license": "MIT", "licenseUrl": "https://github.com/homuler/MediaPipeUnityPlugin/blob/master/LICENSE", diff --git a/mediapipe_api/objc/BUILD b/mediapipe_api/objc/BUILD index efd4dc509..7033085d4 100644 --- a/mediapipe_api/objc/BUILD +++ b/mediapipe_api/objc/BUILD @@ -26,7 +26,7 @@ objc_library( ios_framework( name = "MediaPipeUnity", - bundle_id = "PLEASE_SET_YOUR_BUNDLE_ID_HERE.MediaPipeUnity", + bundle_id = "PLEASE_SET_YOUR_BUNDLE_ID_HERE", families = [ "iphone", "ipad",