Skip to content

Commit a08e72b

Browse files
authored
Merge pull request #348 from CITCOM-project/f-allian/chore
Precompile Wheels for Different OS and Python Versions Before Publishing to PyPI
2 parents 0db9294 + 18b5bdd commit a08e72b

File tree

1 file changed

+73
-12
lines changed

1 file changed

+73
-12
lines changed
Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,93 @@
1-
name: Publish python PyPI
1+
name: Publish to PyPI
22

33
on:
44
push:
55
tags:
66
- v*
77

88
jobs:
9-
build-release:
10-
name: Build and publish PyPI
11-
runs-on: ubuntu-latest
9+
# First job is to build the wheels on different OS
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
1216
steps:
1317
- uses: actions/checkout@v3
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
1421
with:
15-
fetch-depth: 0
22+
python-version: "3.12"
23+
24+
- name: Upgrade pip and install cibuildwheel
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install cibuildwheel
28+
29+
- name: Build wheels
30+
run: python -m cibuildwheel --output-dir wheelhouse
31+
env:
32+
CIBW_BUILD: "cp310-* cp311-* cp312-*"
33+
CIBW_SKIP: "pp* *musllinux*"
34+
CIBW_TEST_SKIP: "*"
35+
CIBW_ARCHS_MACOS: "universal2"
36+
CIBW_ARCHS_LINUX: "x86_64 aarch64"
37+
38+
- name: Upload built wheels
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: wheels-${{ matrix.os }}
42+
path: wheelhouse/*.whl
43+
44+
# Then just build the source distribution as normal
45+
build_sdist:
46+
name: Build source distribution
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
1651
- name: Set up Python
17-
uses: actions/setup-python@v3
52+
uses: actions/setup-python@v4
1853
with:
19-
python-version: '3.10'
54+
python-version: "3.12"
2055

21-
- name: Install build tools
56+
- name: Upgrade pip and install build
2257
run: |
23-
pip install --upgrade pip setuptools wheel build setuptools_scm
58+
python -m pip install --upgrade pip
59+
pip install build
60+
61+
- name: Build sdist
62+
run: python -m build --sdist --outdir dist
63+
64+
- name: Upload sdist
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: sdist
68+
path: dist/*.tar.gz
69+
70+
# Finally publish all files to PyPI
71+
publish:
72+
name: Publish to PyPI
73+
needs: [build_wheels, build_sdist]
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v3
77+
78+
- name: Download all artifacts
79+
uses: actions/download-artifact@v3
80+
with:
81+
path: dist
2482

25-
- name: Build Package
83+
- name: Merge all distributions
2684
run: |
27-
python -m build --no-isolation
85+
mkdir -p final_dist
86+
find dist -name '*.whl' -exec cp {} final_dist/ \;
87+
find dist -name '*.tar.gz' -exec cp {} final_dist/ \;
2888
29-
- name: Publish package to PyPI
89+
- name: Publish to PyPI
3090
uses: pypa/gh-action-pypi-publish@release/v1
3191
with:
3292
password: ${{ secrets.PYPI_API_TOKEN }}
93+
packages_dir: final_dist

0 commit comments

Comments
 (0)