-
Notifications
You must be signed in to change notification settings - Fork 2
230 lines (217 loc) · 8.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
name: build
on:
workflow_dispatch:
push:
paths-ignore:
- "doc/**"
- "**.md"
jobs:
build_linux_macos:
strategy:
fail-fast: false
matrix:
platform:
- name: ubuntu-22.04_x86_64
runs_on: ubuntu-22.04
os: ubuntu
auditwheel_plat: manylinux_2_35_x86_64
- name: ubuntu-20.04_armv8_jetson
runs_on: ubuntu-20.04
os: ubuntu
- name: macos-13_arm64
runs_on: macos-13
os: macos
python_host_platform: "macosx-13.0-arm64"
archflags: "-arch arm64"
python_version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
exclude:
# Jetson は Python 3.8 のみ作成する
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.9"
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.10"
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.11"
runs-on: ${{ matrix.platform.runs_on }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- run: |
sudo apt-get update
sudo apt-get -y install libva-dev libdrm-dev
if: ${{ matrix.platform.os == 'ubuntu' }}
- run: curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION="--yes" bash
- run: echo "$HOME/.rye/shims" >> $GITHUB_PATH
- run: rye pin cpython@${{ matrix.python_version }}
- run: rye sync
# Jetson 以外の Ubuntu 向け
- run: |
rye run python run.py
rye run python -m build
# # auditwheel を適用する
# rm -rf patchelf
# mkdir -p patchelf
# pushd patchelf
# # Ubuntu 20.04 の patchelf は auditwheel が要求するバージョンを満たしてないので
# # リポジトリから新しいバイナリを取得する
# curl -LO https://github.com/NixOS/patchelf/releases/download/0.14.3/patchelf-0.14.3-x86_64.tar.gz
# tar -xf patchelf-0.14.3-x86_64.tar.gz
# popd
# # 共有ライブラリを除ける
# ./scripts/fix_shared_lib.sh src/sora_sdk/*.so > excludes
# PATH=`pwd`/patchelf/bin:$PATH rye run python -m auditwheel repair --plat ${{ matrix.platform.auditwheel_plat }} dist/*.whl `cat excludes`
if: ${{ matrix.platform.os == 'ubuntu' && matrix.platform.name != 'ubuntu-20.04_armv8_jetson' }}
# Jetson 向け
- name: Set up QEMU
if: ${{ matrix.platform.name == 'ubuntu-20.04_armv8_jetson' }}
uses: docker/setup-qemu-action@v2
- run: |
sudo apt-get install -y 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
rye run python run.py
# auditwheel も適用する
# ./scripts/package.ubuntu-20.04_armv8_jetson.sh --with-auditwheel
./scripts/package.ubuntu-20.04_armv8_jetson.sh
if: ${{ matrix.platform.name == 'ubuntu-20.04_armv8_jetson' }}
env:
SORA_SDK_TARGET: ubuntu-20.04_armv8_jetson
# macOS 向け
- run: |
rye run python run.py
rye 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@v3
with:
name: ${{ matrix.platform.name }}_python-${{ matrix.python_version }}
path: "dist/"
build_windows:
runs-on: windows-2019
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python_version }}"
cache: "pip"
- run: pip install -r requirements-dev.lock
- run: python run.py
- run: python -m build
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: windows-2019_python-${{ matrix.python_version }}
path: dist/
publish_wheel:
if: contains(github.ref, 'tags/202')
needs:
- build_linux_macos
- build_windows
strategy:
fail-fast: false
matrix:
platform:
- name: ubuntu-22.04_x86_64
- name: ubuntu-20.04_armv8_jetson
- name: macos-13_arm64
- name: windows-2019
python_version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
exclude:
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.9"
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.10"
- platform: { name: ubuntu-20.04_armv8_jetson }
python_version: "3.11"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/download-artifact@v3
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-13_arm64' && matrix.python_version == '3.8' }}
# テスト用
# - 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 }}
create-release:
if: contains(github.ref, 'tags/202')
needs:
- build_linux_macos
- build_windows
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/download
with: {"platform":"ubuntu-22.04_x86_64", "python_version":"3.8"}
- uses: ./.github/actions/download
with: {"platform":"ubuntu-22.04_x86_64", "python_version":"3.9"}
- 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-20.04_armv8_jetson", "python_version":"3.8"}
- uses: ./.github/actions/download
with: {"platform":"macos-13_arm64", "python_version":"3.8"}
- uses: ./.github/actions/download
with: {"platform":"macos-13_arm64", "python_version":"3.9"}
- uses: ./.github/actions/download
with: {"platform":"macos-13_arm64", "python_version":"3.10"}
- uses: ./.github/actions/download
with: {"platform":"macos-13_arm64", "python_version":"3.11"}
- uses: ./.github/actions/download
with: {"platform":"windows-2019", "python_version":"3.8"}
- uses: ./.github/actions/download
with: {"platform":"windows-2019", "python_version":"3.9"}
- uses: ./.github/actions/download
with: {"platform":"windows-2019", "python_version":"3.10"}
- uses: ./.github/actions/download
with: {"platform":"windows-2019", "python_version":"3.11"}
- 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@v1
with:
files:
${{ steps.env.outputs.package_paths }}