-
Notifications
You must be signed in to change notification settings - Fork 6
206 lines (176 loc) · 6.62 KB
/
release-tmp.yaml
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
name: release-tmp
on:
push:
branches:
- tmp
release:
types: [created]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
python-publish:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v1
- name: Install latest stable Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Set up Python 3.7
id: setup-python-3-7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Set up Python 3.8
id: setup-python-3-8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Set up Python 3.9
id: setup-python-3-9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Set up Python 3.10
id: setup-python-3-10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Set up Python 3.11
id: setup-python-3-11
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Set up Python 3.12
id: setup-python-3-12
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Build wheels (unix)
if: matrix.os != 'windows-latest'
uses: messense/maturin-action@v1
with:
command: build
manylinux: 2014
args: --release --strip --features pybindings -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: Build wheels (windows)
if: matrix.os == 'windows-latest'
uses: messense/maturin-action@v1
with:
command: build
args: --release --strip --features pybindings -i C:\hostedtoolcache\windows\Python\${{ steps.setup-python-3-12.outputs.python-version }}\x64\python3.exe
# For some reason, manylinux builds create wheels owned by the root user,
# which breaks our attempts to add the license file below.
- name: Fix wheel ownership on linux
if: matrix.os == 'ubuntu-latest'
run: sudo chown -R runner:docker target
- name: Cross-build wheels for Apple Silicon
if: matrix.os == 'macos-latest'
uses: messense/maturin-action@v1
with:
target: aarch64-apple-darwin
command: build
args: --release --strip --features pybindings -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: Build universal2 wheels
if: matrix.os == 'macos-latest'
uses: messense/maturin-action@v1
with:
command: build
args: --release --strip --features pybindings --universal2 -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: List wheels (unix)
if: matrix.os != 'windows-latest'
run: ls -l ./target/wheels/
- name: List wheels (windows)
if: matrix.os == 'windows-latest'
run: dir target\wheels\
- name: generate license file
run: |
cargo install cargo-about
cargo about generate --features=pybindings about.hbs > LICENSE.html
ls -l LICENSE.html
wc -l LICENSE.html
- name: Add LICENSE.html to all wheels (unix)
if: matrix.os != 'windows-latest'
run: |
for wheel in target/wheels/*.whl; do
zip -ur $wheel LICENSE.html
done
- name: Add LICENSE.html to all wheels (windows)
if: matrix.os == 'windows-latest'
run: |
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
Get-ChildItem "target\wheels\" -Filter *.whl |
Foreach-Object {
$zip = [System.IO.Compression.ZipFile]::Open($_.FullName, "Update")
$licenseFile = [System.IO.Path]::GetFileName("LICENSE.html")
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, "LICENSE.html", $licenseFile, "Optimal") | Out-Null
$zip.Dispose()
}
- name: Save artifact with wheels for ${{ matrix.os }}
uses: actions/upload-artifact@v2
with:
name: wheels-${{ matrix.os }}
path: ./target/wheels/
- name: Test install wheels (unix)
if: matrix.os != 'windows-latest'
run: |
for i in target/wheels/*.whl; do
echo "Running: pip install $i ..."
pip install "$i" || echo "WARNING: unable to install $i"
echo "Testing if we can import constriction and numpy ..."
python -c 'import constriction; import numpy; print(constriction.__file__)' || echo "WARNING: unable to import constriction or numpy ($i)"
echo "Running: pip uninstall -y constriction numpy"
pip uninstall -y constriction numpy
echo
done
- name: Test install wheels (windows)
if: matrix.os == 'windows-latest'
run: |
$wheels = Get-ChildItem "target\wheels\"
foreach ($wheel in $wheels){
echo "Running: pip install $($wheel.FullName) ..."
try {
pip install "$($wheel.FullName)"
} catch {
echo "WARNING: unable to install $($wheel.FullName)"
}
echo "Testing if we can import constriction and numpy ..."
try {
python -c 'import constriction; import numpy; print(constriction.__file__)'
} catch {
echo "WARNING: unable to import constriction or numpy ($($wheel.FullName))"
}
echo "Running: pip uninstall -y constriction numpy ..."
pip uninstall -y constriction numpy
echo ""
}
- name: Install Python dependencies (for twine)
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Publish wheels (unix)
if: matrix.os != 'windows-latest' && github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
poetry run twine upload target/wheels/*.whl
- name: Publish wheels (windows)
if: matrix.os == 'windows-latest' && github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
$wheels = Get-ChildItem "target\wheels\"
foreach ($wheel in $wheels){
echo "Uploading $($wheel.FullName)"
poetry run twine upload "$($wheel.FullName)"
}