forked from ulaph/UnityOpus
-
Notifications
You must be signed in to change notification settings - Fork 1
232 lines (230 loc) · 7.79 KB
/
build.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
name: Build
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
commit_artifacts:
description: 'Commit artifacts'
required: true
type: choice
options:
- "no"
- "direct"
- "another_branch"
default: "no"
jobs:
build_win64:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- uses: microsoft/[email protected]
with:
msbuild-architecture: x64
vs-version: '[16.0,17.0)' # VS2019
- name: Clone libopus
uses: actions/checkout@v3
with:
repository: xiph/opus
path: 'opus'
ref: v1.3.1
- name: Build libopus
working-directory: opus
shell: bash
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF -DOPUS_BUILD_PROGRAMS=OFF \
-DAVX_SUPPORTED=OFF
cmake --build . --config Release
cp Release/opus.lib ../../Plugin/libopus/lib/Release/opus.lib
- name: Build UnityOpus
working-directory: Plugin
run: |
msbuild UnityOpus.vcxproj /t:build /p:Configuration=Release /p:Platform=x64
- name: Upload
uses: actions/upload-artifact@v3
with:
name: UnityOpus_Win64
path: Plugin/x64/Release/UnityOpus.dll
build_macos:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- run: sudo xcode-select -s /Applications/Xcode_14.3.app
- name: Clone libopus
uses: actions/checkout@v3
with:
repository: xiph/opus
path: 'opus'
ref: v1.3.1
- name: Build libopus
working-directory: opus
run: |
mkdir build
cd build
cmake .. -G "Xcode" -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF -DOPUS_BUILD_PROGRAMS=OFF \
-DMACOSX_DEPLOYMENT_TARGET=10.13 -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
cmake --build . --config Release
cp Release/libopus.a ../../Plugin/libopus/lib/Release/libopus.a
- name: Build UnityOpus
working-directory: Plugin/mac
run: |
rm -r ../../Assets/Plugins/UnityOpus/Plugins/Mac/UnityOpus.bundle
xcodebuild -project UnityOpus/UnityOpus.xcodeproj -configuration Release -target UnityOpus
cd UnityOpus/build/Release/
tar czf UnityOpus.bundle.tar.gz UnityOpus.bundle
- name: Upload
uses: actions/upload-artifact@v3
with:
name: UnityOpus_macOS
path: Plugin/mac/UnityOpus/build/Release/UnityOpus.bundle.tar.gz
build_ios:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- run: sudo xcode-select -s /Applications/Xcode_14.3.app
- name: Clone libopus
uses: actions/checkout@v3
with:
repository: xiph/opus
path: 'opus'
ref: v1.3.1
- name: Build libopus
working-directory: opus
run: |
mkdir build
cd build
cmake .. -G "Xcode" -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF -DOPUS_BUILD_PROGRAMS=OFF \
-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build . --config Release
- name: Upload
uses: actions/upload-artifact@v3
with:
name: libopus_iOS
path: opus/build/Release-iphoneos/libopus.a
build_android:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Clone libopus
uses: actions/checkout@v3
with:
repository: xiph/opus
path: Plugin/libopus/src
ref: v1.3.1
- name: Download NDK 21
run: |
wget -q https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
sha1sum -c <(echo "c3ebc83c96a4d7f539bd72c241b2be9dcd29bda9 android-ndk-r21e-linux-x86_64.zip")
unzip -qq android-ndk-r21e-linux-x86_64.zip
- name: Build UnityOpus
working-directory: Plugin/android
run: |
./gradlew assembleRelease
env:
ANDROID_NDK_HOME: ${{ github.workspace }}/android-ndk-r21e
- name: Upload
uses: actions/upload-artifact@v3
with:
name: UnityOpus_Android
path: Plugin/android/unityopus/build/outputs/aar/unityopus-release.aar
make_all_zip:
runs-on: ubuntu-22.04
needs:
- build_win64
- build_macos
- build_ios
- build_android
steps:
- name: Download Win64 artifact
uses: actions/download-artifact@v3
with:
name: UnityOpus_Win64
path: dest/x64/
- name: Download macOS artifact
uses: actions/download-artifact@v3
with:
name: UnityOpus_macOS
path: dest/Mac/
- name: Download iOS artifact
uses: actions/download-artifact@v3
with:
name: libopus_iOS
path: dest/iOS/lib/
- name: Download Android artifact
uses: actions/download-artifact@v3
with:
name: UnityOpus_Android
path: dest/Android/
- name: Extract macOS bundle
run: |
cd dest/Mac
tar xzf UnityOpus.bundle.tar.gz
rm UnityOpus.bundle.tar.gz
- name: Rename Android AAR
run: |
cd dest/Android
mv unityopus-release.aar unityopus.aar
- name: Create zip
run: cd dest && zip -r ../UnityOpus_Plugins.zip .
- name: Write Checksums
run: |
cd dest
echo -e '## Checksums\n```' >> $GITHUB_STEP_SUMMARY
find . -type f -exec sha512sum {} \; >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v3
with:
name: Plugins
path: UnityOpus_Plugins.zip
commit_artifacts:
runs-on: ubuntu-22.04
needs:
- make_all_zip
if: github.event.inputs.commit_artifacts == 'direct' || github.event.inputs.commit_artifacts == 'another_branch'
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: Plugins
path: dest/
- name: Extract plugins zip
run: unzip dest/UnityOpus_Plugins.zip -d dest && rm dest/UnityOpus_Plugins.zip
- name: Copy files
shell: python
run: |
import os
import glob
SRC_DIR = "dest"
DEST_DIR = "Assets/Plugins/UnityOpus/Plugins"
for f in glob.glob(os.path.join(SRC_DIR, "**", "*"), recursive=True):
if not os.path.isfile(f):
continue
# .meta がないと Unity で開いた時に追加で diff が出るので、.meta がない場合はエラーにする
if not os.path.exists(f.replace(SRC_DIR, DEST_DIR)):
raise Exception("New file (need to generate .meta): " + f.replace(SRC_DIR, DEST_DIR))
os.rename(f, f.replace(SRC_DIR, DEST_DIR))
- name: Create new branch
if: github.event.inputs.commit_artifacts == 'another_branch'
run: |
git checkout -b "gha/$(git rev-parse --abbrev-ref HEAD)"
- name: Commit
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Assets/Plugins/UnityOpus/Plugins
git commit -m "Update binaries\n\nSource: $(git rev-parse HEAD)"
- name: Push (Force)
if: github.event.inputs.commit_artifacts == 'another_branch'
run: |
git push -f origin "$(git rev-parse --abbrev-ref HEAD)"
- name: Push
if: github.event.inputs.commit_artifacts == 'direct'
run: |
git push origin "$(git rev-parse --abbrev-ref HEAD)"