-
Notifications
You must be signed in to change notification settings - Fork 13
238 lines (229 loc) · 8.22 KB
/
CI.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
name: CI
on:
push:
branches:
- main
tags:
- '*'
jobs:
build:
name: "Build on ${{ matrix.platform.name }} with Python ${{ matrix.python.version }}"
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
python: [
{
name: "cp38-cp38",
version: "3.8"
},
{
name: "cp39-cp39",
version: "3.9"
},
{
name: "cp310-cp310",
version: "3.10"
},
{
name: "cp311-cp311",
version: "3.11"
},
]
rust: [stable]
platform: [
{
os: "ubuntu-20.04",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
name: "Ubuntu 20.04"
},
{
os: "ubuntu-latest",
python-architecture: "x64",
rust-target: "x86_64-unknown-linux-gnu",
name: "Ubuntu Latest"
},
{
os: "macos-13",
python-architecture: "x64",
rust-target: "aarch64-apple-darwin",
name: "macOS arm64"
},
{
os: "macos-13",
python-architecture: "x64",
rust-target: "x86_64-apple-darwin",
name: "macOS x64"
},
# {
# os: "windows-latest",
# python-architecture: "x86",
# rust-target: "i686-pc-windows-msvc",
# name: "Windows x86"
# },
{
os: "windows-latest",
python-architecture: "x64",
rust-target: "x86_64-pc-windows-msvc",
name: "Windows x64"
},
]
fail-fast: false
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.platform.python-architecture }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.platform.python-architecture }}-cargo-${{ matrix.rust }}-
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python.version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.platform.rust-target }}
default: true
profile: minimal
override: true
- name: Install CLang
uses: KyleMayes/install-llvm-action@v1
with:
version: "15.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> ${GITHUB_ENV}
if: runner.os == 'Windows'
- name: Install dependencies
run: pip install maturin pygithub
if: matrix.platform.rust-target != 'x86_64-unknown-linux-gnu'
- name: Install dependencies
# Only need patch elf on linux
run: pip install maturin[patchelf] pygithub
if: matrix.platform.rust-target == 'x86_64-unknown-linux-gnu'
# - name: Install dependencies OSX
# run: brew install pkg-config ffmpeg imagemagick
# if: matrix.platform.os == 'macos-13'
- name: Install Deps Linux
run: |
sudo apt-get update \
&& sudo apt-get install -y \
libdbus-1-dev libssl-dev \
clang libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libavutil-dev pkg-config \
if: runner.os == 'Linux'
- name: Install ffmpeg dependencies windows
env:
FFMPEG_DOWNLOAD_URL: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z
run: |
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
Invoke-WebRequest "${env:FFMPEG_DOWNLOAD_URL}" -OutFile ffmpeg-release-full-shared.7z
7z x ffmpeg-release-full-shared.7z
mkdir ffmpeg
mv ffmpeg-*/* ffmpeg/
Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n"
Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n"
if: runner.os == 'Windows'
- name: Build package Linux
env:
PY_VERSION: ${{ matrix.python.name }}
run: cd oxen && maturin build --out dist --release --interpreter ${PY_LOCATION}/bin/python
if: runner.os == 'Linux'
- name: Debug C++
run: |
which c++
c++ --version
- name: Build package macOS x86
env:
PY_LOCATION: ${{ env.pythonLocation }}
CXXFLAGS: "-fno-aligned-allocation"
MACOSX_DEPLOYMENT_TARGET: '13.0'
# CPLUS_INCLUDE_PATH: ${{ runner.temp }}/llvm/include/c++/v1/
run: cd oxen && maturin build --out dist --release --interpreter ${PY_LOCATION}/bin/python
if: matrix.platform.rust-target == 'x86_64-apple-darwin'
- name: Build package macOS arm64
env:
PY_LOCATION: ${{ env.pythonLocation }}
run: cd oxen && maturin build --out dist --release --interpreter ${PY_LOCATION}/bin/python
if: matrix.platform.rust-target == 'aarch64-apple-darwin'
- name: Build package Windows
env:
PY_LOCATION: ${{ env.pythonLocation }}
run: cd oxen && maturin build --out dist --release --interpreter ${env:PY_LOCATION}\python.exe
if: runner.os == 'Windows'
- name: Build Ubuntu 20.04
env:
PY_LOCATION: ${{ env.pythonLocation }}
# This one does not have --sdist because we do it in Ubuntu Latest
run: cd oxen && maturin build --release --out dist --interpreter ${PY_LOCATION}/bin/python
# run: cd oxen && docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin build --release --out dist
if: matrix.platform.name == 'Ubuntu 20.04'
- name: Build linux package sdist
env:
PY_LOCATION: ${{ env.pythonLocation }}
# This packages up the source with --sdist
run: cd oxen && maturin build --release --out dist --sdist --interpreter ${PY_LOCATION}/bin/python
if: matrix.platform.name == 'Ubuntu Latest'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: oxen/dist
# sdist:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Build sdist
# uses: PyO3/maturin-action@v1
# with:
# command: sdist
# args: --out dist
# working-directory: oxen
# - name: Upload sdist
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [build]
steps:
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
id: download
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
- name: List downloaded wheels
run: echo ${{steps.download.outputs.download-path}} && ls -R ${{steps.download.outputs.download-path}}
- name: Move assets into a directory
# Do this before zipping unless we will get file changed as we read it error
run: mkdir wheels ; mv ${{steps.download.outputs.download-path}}/oxenai* wheels/
- name: Create tarball with wheels
run: tar -czvf wheels.tar.gz wheels/
- name: Upload wheels to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: wheels.tar.gz
asset_name: wheels.tar.gz
tag: ${{ github.ref }}
release_name: "🐍 Release ${{ github.ref }}"