Skip to content

Commit 2a1412b

Browse files
authored
Refactor Actions for building and publishing wheels
1 parent c7d2d5a commit 2a1412b

File tree

1 file changed

+88
-20
lines changed

1 file changed

+88
-20
lines changed

.github/workflows/wheels.yml

Lines changed: 88 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,106 @@
1-
name: Build Wheels (cbuild-nox)
1+
name: Build and Publish Wheels
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main, develop ]
49

510
jobs:
6-
build_wheels:
11+
build:
712
name: Build wheels on ${{ matrix.os }}
813
runs-on: ${{ matrix.os }}
914
strategy:
15+
fail-fast: false
1016
matrix:
11-
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-latest]
17+
os: [ubuntu-latest, windows-latest, macos-latest]
1218

1319
steps:
1420
- uses: actions/checkout@v5
1521

16-
# Used to host cibuildwheel
17-
- uses: actions/setup-python@v5
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
1824
with:
1925
python-version: '3.11'
2026
cache: 'pip'
2127

22-
- name: Install cibuildwheel
23-
run: python -m pip install cibuildwheel==3.2.1
28+
- name: Install build dependencies
29+
run: python -m pip install --upgrade pip setuptools wheel build
2430

25-
- name: Build wheels
26-
run: python -m cibuildwheel --output-dir wheelhouse
27-
env:
28-
# Build for Python 3.8 through 3.12
29-
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
30-
# Skip PyPy builds
31-
CIBW_SKIP: pp*
32-
# Test before building (optional)
33-
CIBW_TEST_COMMAND: python -c "import libcrypto; print(f'libcrypto {libcrypto.__version__}')"
31+
- name: Build wheel and sdist
32+
run: python -m build
3433

35-
- uses: actions/upload-artifact@v4
34+
- name: List built artifacts
35+
shell: bash
36+
run: ls -lh dist/
37+
38+
- name: Upload artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: wheels-${{ matrix.os }}
42+
path: dist/
43+
retention-days: 7
44+
45+
test:
46+
name: Test on Python ${{ matrix.python-version }}
47+
runs-on: ubuntu-latest
48+
needs: build
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
53+
54+
steps:
55+
- uses: actions/checkout@v5
56+
57+
- name: Set up Python ${{ matrix.python-version }}
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
cache: 'pip'
62+
63+
- name: Download built wheel
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: wheels-ubuntu-latest
67+
path: dist/
68+
69+
- name: Install wheel
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install dist/*.whl
73+
74+
- name: Install test dependencies
75+
run: pip install pytest pytest-cov
76+
77+
- name: Run tests
78+
run: pytest -v
79+
80+
publish:
81+
name: Publish to PyPI
82+
if: startsWith(github.ref, 'refs/tags/')
83+
needs: test
84+
runs-on: ubuntu-latest
85+
environment:
86+
name: pypi
87+
url: https://pypi.org/p/libcrypto
88+
89+
steps:
90+
- uses: actions/checkout@v5
91+
92+
- name: Set up Python
93+
uses: actions/setup-python@v5
94+
with:
95+
python-version: '3.11'
96+
97+
- name: Install build dependencies
98+
run: python -m pip install --upgrade pip build
99+
100+
- name: Build wheel and sdist
101+
run: python -m build
102+
103+
- name: Publish to PyPI
104+
uses: pypa/gh-action-pypi-publish@release/v1
36105
with:
37-
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
38-
path: ./wheelhouse/*.whl
106+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)