-
Notifications
You must be signed in to change notification settings - Fork 3
346 lines (330 loc) · 12 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
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
344
345
346
name: build
on:
push:
paths-ignore:
- "examples/**"
- "**.md"
# schedule:
# # UTC の 01:00 は JST だと 10:00 。
# # 1-5 で 月曜日から金曜日
# - cron: "0 1 * * 1-5"
env:
TEST_SIGNALING_URLS: ${{ secrets.TEST_SIGNALING_URLS }}
TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }}
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}
TEST_API_URL: ${{ secrets.TEST_API_URL }}
jobs:
# まず pyi を生成する
# クロスコンパイル環境だと pyi が生成できないので、
# 1箇所で pyi を生成してアーティファクトにアップロードして、
# それを各ビルドで利用する形にする。
build_pyi:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- run: |
sudo apt-get -y install libx11-dev
- uses: astral-sh/setup-uv@v5
with:
enable-cache: false
- run: uv python pin 3.13
- run: uv sync
- name: Generate pyi
run: |
uv run python run.py ubuntu-24.04_x86_64
mkdir sora_sdk/
cp src/sora_sdk/py.typed sora_sdk/
cp src/sora_sdk/sora_sdk_ext.pyi sora_sdk/
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: sora_sdk
path: sora_sdk/
build_linux_macos:
strategy:
fail-fast: false
matrix:
platform:
# - name: ubuntu-24.04_x86_64
# target: ubuntu-24.04_x86_64
# runs_on: ubuntu-24.04
# os: ubuntu
- name: ubuntu-22.04_x86_64
target: ubuntu-22.04_x86_64
runs_on: ubuntu-22.04
os: ubuntu
arch: x86_64
- name: macos-15_arm64
target: macos_arm64
runs_on: macos-15
os: macos
python_host_platform: "macosx-15.0-arm64"
archflags: "-arch arm64"
- name: macos-14_arm64
target: macos_arm64
runs_on: macos-14
os: macos
python_host_platform: "macosx-14.0-arm64"
archflags: "-arch arm64"
python_version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
include:
- platform:
name: ubuntu-24.04_armv8
target: ubuntu-24.04_armv8
runs_on: ubuntu-24.04
os: ubuntu
arch: armv8
python_version: "3.12"
needs: [build_pyi]
runs-on: ${{ matrix.platform.runs_on }}
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: sora_sdk
path: sora_sdk/
- run: |
cp sora_sdk/py.typed src/sora_sdk/py.typed
cp sora_sdk/sora_sdk_ext.pyi src/sora_sdk/sora_sdk_ext.pyi
# libx11-dev は Ubuntu 24.04 の時に必要になる模様
- run: |
sudo apt-get update
sudo apt-get -y install libx11-dev
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64' }}
- run: |
sudo apt-get -y install multistrap binutils-aarch64-linux-gnu
# multistrap に insecure なリポジトリからの取得を許可する設定を入れる
sudo sed -e 's/Apt::Get::AllowUnauthenticated=true/Apt::Get::AllowUnauthenticated=true";\n$config_str .= " -o Acquire::AllowInsecureRepositories=true/' -i /usr/sbin/multistrap
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'armv8' }}
- uses: astral-sh/setup-uv@v5
with:
enable-cache: false
- run: uv python pin ${{ matrix.python_version }}
- run: uv sync
# Ubuntu x86_64 向け
- name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64' }}
- run: |
uv run python run.py ${{ matrix.platform.target }}
uv run python -m build
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64' }}
# Ubuntu armv8 向け
- run: |
uv run python run.py ${{ matrix.platform.target }}
uv run python -m build
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'armv8' }}
env:
SORA_SDK_TARGET: ${{ matrix.platform.target }}
# Ubuntu 向けに Python 3.10 では E2E テストを実行する
- name: Download openh264
run: |
curl -LO http://ciscobinary.openh264.org/libopenh264-2.4.1-linux64.7.so.bz2
bzip2 -d libopenh264-2.4.1-linux64.7.so.bz2
mv libopenh264-2.4.1-linux64.7.so libopenh264.so
echo "OPENH264_PATH=$(pwd)/libopenh264.so" >> $GITHUB_ENV
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64' && matrix.python_version == '3.10' }}
- run: uv run pytest tests -s
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64' && matrix.python_version == '3.10' }}
# macOS 向け
- run: |
uv run python run.py ${{ matrix.platform.target }}
uv run python -m build
if: ${{ matrix.platform.os == 'macos' }}
env:
_PYTHON_HOST_PLATFORM: ${{ matrix.platform.python_host_platform }}
ARCHFLAGS: ${{ matrix.platform.archflags }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.name }}_python-${{ matrix.python_version }}
path: "dist/"
build_windows:
needs: [build_pyi]
runs-on: windows-2022
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python_version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: sora_sdk
path: sora_sdk/
- run: |
cp sora_sdk/py.typed src/sora_sdk/py.typed
cp sora_sdk/sora_sdk_ext.pyi src/sora_sdk/sora_sdk_ext.pyi
- uses: astral-sh/setup-uv@v5
with:
enable-cache: false
- run: uv python pin ${{ matrix.python_version }}
- run: uv sync
- run: uv run python run.py windows_x86_64
- run: uv run python -m build
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: windows-2022_python-${{ matrix.python_version }}
path: dist/
slack_notify_succeeded:
needs: [build_linux_macos, build_windows]
runs-on: ubuntu-24.04
if: success()
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: sora-python-sdk
SLACK_COLOR: good
SLACK_TITLE: SUCCEEDED
SLACK_ICON_EMOJI: ":star-struck:"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
slack_notify_failed:
needs: [build_linux_macos, build_windows]
runs-on: ubuntu-24.04
if: failure()
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: sora-python-sdk
SLACK_COLOR: danger
SLACK_TITLE: "FAILED"
SLACK_ICON_EMOJI: ":japanese_ogre:"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
publish_wheel:
if: contains(github.ref, 'tags/202')
needs:
- build_linux_macos
- build_windows
strategy:
fail-fast: false
matrix:
platform:
# - name: ubuntu-24.04_x86_64
- name: ubuntu-22.04_x86_64
- name: macos-15_arm64
- name: macos-14_arm64
- name: windows-2022
python_version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
include:
- platform:
name: ubuntu-24.04_armv8
python_version: "3.12"
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.platform.name }}_python-${{ matrix.python_version }}
path: dist
- run: |
if [ -e dist/*.tar.gz ]; then
mv dist/*.tar.gz ./
fi
# matrix の中で1個だけソースディストリビューション用のデータを残しておく
- run: mv *.tar.gz dist/
if: ${{ matrix.platform.name == 'macos-15_arm64' && matrix.python_version == '3.10' }}
# テスト用
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
# verbose: true
# 本番用
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: sora-python-sdk
SLACK_COLOR: danger
SLACK_TITLE: Build failed
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
create-release:
if: contains(github.ref, 'tags/202')
needs:
- build_linux_macos
- build_windows
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/download
with: { "platform": "ubuntu-22.04_x86_64", "python_version": "3.10" }
- uses: ./.github/actions/download
with: { "platform": "ubuntu-22.04_x86_64", "python_version": "3.11" }
- uses: ./.github/actions/download
with: { "platform": "ubuntu-22.04_x86_64", "python_version": "3.12" }
- uses: ./.github/actions/download
with: { "platform": "ubuntu-22.04_x86_64", "python_version": "3.13" }
- uses: ./.github/actions/download
with: { "platform": "ubuntu-24.04_armv8", "python_version": "3.12" }
- uses: ./.github/actions/download
with: { "platform": "macos-15_arm64", "python_version": "3.10" }
- uses: ./.github/actions/download
with: { "platform": "macos-15_arm64", "python_version": "3.11" }
- uses: ./.github/actions/download
with: { "platform": "macos-15_arm64", "python_version": "3.12" }
- uses: ./.github/actions/download
with: { "platform": "macos-15_arm64", "python_version": "3.13" }
- uses: ./.github/actions/download
with: { "platform": "macos-14_arm64", "python_version": "3.10" }
- uses: ./.github/actions/download
with: { "platform": "macos-14_arm64", "python_version": "3.11" }
- uses: ./.github/actions/download
with: { "platform": "macos-14_arm64", "python_version": "3.12" }
- uses: ./.github/actions/download
with: { "platform": "macos-14_arm64", "python_version": "3.13" }
- uses: ./.github/actions/download
with: { "platform": "windows-2022", "python_version": "3.10" }
- uses: ./.github/actions/download
with: { "platform": "windows-2022", "python_version": "3.11" }
- uses: ./.github/actions/download
with: { "platform": "windows-2022", "python_version": "3.12" }
- uses: ./.github/actions/download
with: { "platform": "windows-2022", "python_version": "3.13" }
- name: Env to output
run: |
echo "package_paths<<EOF" >> $GITHUB_OUTPUT
cat package_paths.env >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
id: env
- name: Release
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.env.outputs.package_paths }}
prerelease: ${{ contains(github.ref, 'dev') }}
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: sora-python-sdk
SLACK_COLOR: danger
SLACK_ICON_EMOJI: ":japanese_ogre:"
SLACK_TITLE: Release failed
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}