-
Notifications
You must be signed in to change notification settings - Fork 14
198 lines (171 loc) · 5.13 KB
/
deploy-package-to-pypi.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
name: Deploy package to PyPI
# on:
# release:
# types: [published]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-source:
name: Build source package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
- uses: actions/setup-python@v4
with:
python-version: 3.13
- name: Build package
run: |
pip install build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: source
path: ./dist
build-linux:
name: Build Linux wheels
runs-on: ubuntu-latest
strategy:
matrix:
image:
- "manylinux2014_x86_64"
- "musllinux_1_1_x86_64"
- "manylinux2014_aarch64"
- "musllinux_1_1_aarch64"
folder:
- "cp37-cp37m"
- "cp38-cp38"
- "cp39-cp39"
- "cp310-cp310"
- "cp311-cp311"
- "cp312-cp312"
- "cp313-cp313"
steps:
- uses: actions/checkout@v4
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build packages
run: >-
docker run --rm -v ${{ github.workspace }}:/app quay.io/pypa/${{ matrix.image }} bash -c '
cd /app &&
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y &&
. "$HOME/.cargo/env" &&
/opt/python/${{ matrix.folder }}/bin/pip install pipx
pipx install maturin
maturin build --out dist
auditwheel repair $(ls dist/*.whl) &&
rm dist/*.whl &&
cp wheelhouse/*.whl dist
'
- uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.image }}-$${{ matrix.folder }}
path: ./dist
build-macos:
name: Build macOS wheels
strategy:
matrix:
os:
- "macos-12"
- "macos-13"
- "macos-14" # ARM
python-version:
- "3.7.1"
- "3.8.10"
- "3.9.13"
- "3.10.11"
- "3.11.9"
- "3.12.6"
- "3.13.0"
exclude:
- python-version: "3.7.1"
os: "macos-14"
runs-on: '${{ matrix.os }}'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.python-version }}'
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "" "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
- name: Build package
run: |
pip install pipx
pipx install maturin
maturin build --out dist
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.python-version }}
path: ./dist
build-windows:
name: Build Windows wheels
strategy:
matrix:
os:
- "windows-2019"
python-version:
- "3.7.1"
- "3.8.0"
- "3.9.0"
- "3.10.0"
- "3.11.0"
- "3.12.0"
- "3.13.0"
runs-on: '${{ matrix.os }}'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '${{ matrix.python-version }}'
# - name: Update version in pyproject.toml from current git tag
# run: |
# (Get-Content pyproject.toml).Replace('0.0.0.dev0', ($Env:GITHUB_REF_NAME).Replace('v', '')) | Set-Content pyproject.toml
- name: Build package
run: |
pip install pipx
pipx install maturin
maturin build --out dist
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.python-version }}
path: ./dist
deploy:
needs:
- build-source
- build-linux
- build-macos
- build-windows
environment:
name: pypi
url: https://pypi.org/project/stream-unzip/
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: ./dist
# The "merge-multiple" option of download-artifact seems to cause corruption when there are
# multiple files of the same name, which happens because in some different macOS versions
# make the exact same Python package. So we avoid that and do a manual move of packages
# to the top level for upload
- name: Move packages to top level
run: |
find ./dist -mindepth 2 -type f -exec mv -t ./dist -i '{}' +
rm -R -- ./dist/*/
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages_dir: ./dist/