11name : Wheels
2-
32on :
43 workflow_dispatch :
54 pull_request :
65 push :
76 branches :
87 - master
8+ - main
99 release :
1010 types :
1111 - published
@@ -18,64 +18,93 @@ jobs:
1818 - uses : actions/checkout@v4
1919 with :
2020 submodules : true
21-
21+
2222 - name : Build SDist
2323 run : pipx run build --sdist
24-
24+
2525 - name : Check metadata
2626 run : pipx run twine check dist/*
27-
27+
2828 - uses : actions/upload-artifact@v4
2929 with :
3030 name : cibw-sdist
3131 path : dist/*.tar.gz
3232
33-
3433 build_wheels :
35- name : Wheels on ${{ matrix.os }}
36- runs-on : ${{ matrix.os }}
34+ name : Build wheels on Linux
35+ runs-on : ubuntu-latest
3736 strategy :
3837 fail-fast : false
3938 matrix :
40- os : [ubuntu-latest, windows-latest, macos-13]
41-
39+ # Build for both x86_64 and aarch64
40+ arch : [x86_64, aarch64]
41+
4242 steps :
4343 - uses : actions/checkout@v4
4444 with :
4545 submodules : true
46-
47- 46+
47+ # Set up QEMU for aarch64 emulation
48+ - name : Set up QEMU
49+ if : matrix.arch == 'aarch64'
50+ uses : docker/setup-qemu-action@v3
51+ with :
52+ platforms : arm64
53+
54+ - name : Build wheels
55+ 4856 env :
49- CIBW_ARCHS_MACOS : auto universal2
50-
57+ # Only build for Linux
58+ CIBW_PLATFORM : linux
59+ CIBW_ARCHS_LINUX : ${{ matrix.arch }}
60+
61+ # Python versions to build for
62+ CIBW_BUILD : " cp38-* cp39-* cp310-* cp311-* cp312-*"
63+ CIBW_SKIP : " *-musllinux*" # Skip musl builds, focus on glibc
64+
65+ # Install system dependencies before building
66+ CIBW_BEFORE_ALL_LINUX : >
67+ yum install -y epel-release &&
68+ yum install -y libbpf-devel kernel-headers ||
69+ (apt-get update && apt-get install -y libbpf-dev linux-headers-generic)
70+
71+ # Test the built wheels
72+ CIBW_TEST_COMMAND : " python -c 'import pylibbpf; print(f\" pylibbpf {pylibbpf.__version__} imported successfully\" )'"
73+
74+ # Skip testing on emulated architectures (too slow)
75+ CIBW_TEST_SKIP : " *-linux_aarch64"
76+
5177 - name : Verify clean directory
5278 run : git diff --exit-code
5379 shell : bash
54-
80+
5581 - name : Upload wheels
5682 uses : actions/upload-artifact@v4
5783 with :
58- name : cibw-wheels-${{ matrix.os }}
84+ name : cibw-wheels-linux- ${{ matrix.arch }}
5985 path : wheelhouse/*.whl
6086
61-
6287 upload_all :
63- name : Upload if release
88+ name : Upload to PyPI if release
6489 needs : [build_wheels, build_sdist]
6590 runs-on : ubuntu-latest
6691 if : github.event_name == 'release' && github.event.action == 'published'
67-
92+ permissions :
93+ # IMPORTANT: this permission is mandatory for trusted publishing
94+ id-token : write
95+ environment :
96+ name : pypi
97+ # url: https://pypi.org/project/pylibbpf/${{ github.event.release.name }}
98+
6899 steps :
69- - uses : actions/setup-python@v5
70- with :
71- python-version : " 3.x"
72-
73- - uses : actions/download-artifact@v4
100+ - name : Download all artifacts
101+ uses : actions/download-artifact@v4
74102 with :
75103 pattern : cibw-*
76104 path : dist
77105 merge-multiple : true
78-
79- - uses : pypa/gh-action-pypi-publish@release/v1
106+
107+ - name : Publish to PyPI
108+ uses : pypa/gh-action-pypi-publish@release/v1
80109 with :
81- password : ${{ secrets.pypi_password }}
110+ packages-dir : dist/
0 commit comments