-
-
Notifications
You must be signed in to change notification settings - Fork 467
343 lines (303 loc) · 11.4 KB
/
package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Package
on:
workflow_call:
inputs:
ref:
type: string
required: true
packageName:
type: string
default: package
bazelBuildArgs:
type: string
default: '--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0'
linuxBuildArgs:
type: string
default: '--desktop gpu --opencv cmake'
androidBuildArgs:
type: string
default: '--android arm64 --android_ndk_api_level 21'
macosBuildArgs:
type: string
default: '--desktop cpu --opencv cmake --macos_universal'
iosBuildArgs:
type: string
default: '--ios arm64'
windowsBuildArgs:
type: string
default: '--desktop cpu --opencv cmake'
secrets:
UNITY_EMAIL:
required: false
UNITY_PASSWORD:
required: false
UNITY_TOTP_KEY:
required: false
jobs:
print-inputs:
runs-on: ubuntu-latest
steps:
- name: Print inputs for debug
run: |
echo 'inputs.ref=${{ inputs.ref }}'
echo 'inputs.bazelBuildArgs=${{ inputs.bazelBuildArgs }}'
echo 'inputs.linuxBuildArgs=${{ inputs.linuxBuildArgs }}'
echo 'inputs.androidBuildArgs=${{ inputs.androidBuildArgs }}'
echo 'inputs.macosBuildArgs=${{ inputs.macosBuildArgs }}'
echo 'inputs.iosBuildArgs=${{ inputs.iosBuildArgs }}'
echo 'inputs.windowsBuildArgs=${{ inputs.windowsBuildArgs }}'
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.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
- name: Remove unused files to free up space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
- name: Build
run: |
docker run --rm \
--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="${{ inputs.bazelBuildArgs }}" ${{ inputs.linuxBuildArgs }} -vv
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-base
path: .
android-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.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
- name: Remove unused files to free up space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
- name: Build
run: |
docker run --rm \
--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="${{ inputs.bazelBuildArgs }}" ${{ inputs.androidBuildArgs }} -vv
- name: Upload mediapipe_android.aar
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-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@v4
with:
ref: ${{ inputs.ref }}
# Setup Python
- uses: actions/setup-python@v5
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="${{ inputs.bazelBuildArgs }}" ${{ inputs.macosBuildArgs }} -vv
- name: Upload libmediapipe_c.dylib
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-libmediapipe_c.dylib
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/libmediapipe_c.dylib
ios-build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
# Setup Python
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install NumPy
run: pip install --no-cache-dir --user numpy
- name: Build MediaPipeUnity.framework
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="${{ inputs.bazelBuildArgs }}" ${{ inputs.iosBuildArgs }} -vv
- name: Upload MediaPipeUnity.framework
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-MediaPipeUnity.framework
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework
windows-build:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Build a Docker image
run: |
docker build --no-cache -t mediapipe_unity:latest . -f docker/windows/x86_64/Dockerfile
shell: cmd
timeout-minutes: 60
- name: Build
run: |
docker run --rm --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="${{ inputs.bazelBuildArgs }}" ${{ inputs.windowsBuildArgs }} -vv
shell: cmd
- name: Upload mediapipe_c.dll
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-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: Check options
run: |
if [[ -z '${{ secrets.UNITY_EMAIL }}' ]]; then
echo "BUILD_UNITYPACKAGE=0" >> $GITHUB_ENV
else
echo "BUILD_UNITYPACKAGE=1" >> $GITHUB_ENV
fi
# avoid "No space left on device" error
- name: Remove unused files to free up space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
- name: Install UnityEditor
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
run: |
sudo docker cp $(docker create --rm unityci/editor:2022.3.34f1-base-3):/opt/unity /opt/unity
sudo chown -R $(id -u):$(id -g) /opt/unity
echo -e '#!/bin/bash\nxvfb-run -ae /dev/stdout /opt/unity/Editor/Unity -batchmode "$@"' | sudo tee -a /usr/bin/unity-editor
sudo chmod +x /usr/bin/unity-editor
- name: Generate a license activation file
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
run: |
unity-editor -quit -createManualActivationFile -logFile || true
- name: Request a Unity license file
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_TOTP_KEY: ${{ secrets.UNITY_TOTP_KEY }}
run: |
npm install -g unity-verify-code
git clone https://github.com/homuler/unity-license-activate.git
cd unity-license-activate
npm install
cd ..
npm install -g ./unity-license-activate
unity-license-activate "$UNITY_EMAIL" "$UNITY_PASSWORD" Unity_v2022.3.34f1.alf --authenticator-key "$UNITY_TOTP_KEY"
rm -rf unity-license-activate
- name: Activate License
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
run: |
unity-editor -quit -batchmode -nographics -logFile -manualLicenseFile $(ls Unity_*.ulf) || true
rm Unity_*.alf
rm Unity_*.ulf
- name: Download the base package
uses: actions/download-artifact@v4
with:
name: ${{ inputs.packageName }}-base
- name: Download mediapipe_android.aar
uses: actions/download-artifact@v4
with:
name: ${{ inputs.packageName }}-mediapipe_android.aar
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/Android
- name: Download libmediapipe_c.dylib
uses: actions/download-artifact@v4
with:
name: ${{ inputs.packageName }}-libmediapipe_c.dylib
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins
- name: Download MediaPipeUnity.framework
uses: actions/download-artifact@v4
with:
name: ${{ inputs.packageName }}-MediaPipeUnity.framework
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework
- name: Download mediapipe_c.dll
uses: actions/download-artifact@v4
with:
name: ${{ inputs.packageName }}-mediapipe_c.dll
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins
- name: Zip all
run: |
zip -r MediaPipeUnityPlugin-all.zip . -x .git/**\*
- name: Upload MediaPipeUnityPlugin-all.zip
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-src-all
path: |
MediaPipeUnityPlugin-all.zip
retention-days: 7
# avoid "No space left on device" error
- name: Remove uploaded files to free up space
run: |
rm MediaPipeUnityPlugin-all.zip
# NOTE: this step will overwrite AppSettings.asset
- name: Export unitypackage
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
run: |
unity-editor -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
- name: Upload the unitypackage
if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-unitypackage
path: |
*.unitypackage
retention-days: 7
- name: Export tarball
run: |
cd Packages/com.github.homuler.mediapipe
npm pack
mv com.github.homuler.mediapipe-*.tgz ../..
- name: Upload the tarball package
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.packageName }}-tarball
path: |
com.github.homuler.mediapipe-*.tgz
retention-days: 7
clean:
runs-on: ubuntu-latest
needs:
- package
steps:
- uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.packageName }}-base
failOnError: false
- uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.packageName }}-mediapipe_android.aar
failOnError: false
- uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.packageName }}-libmediapipe_c.dylib
failOnError: false
- uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.packageName }}-MediaPipeUnity.framework
failOnError: false
- uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.packageName }}-mediapipe_c.dll
failOnError: false