Debian Codegraph @

.github/workflows/python-publish-release.yml

raw symbols SCIP
1 name: RELEASE BUILD - PyPI 📦 Distribution
2
3 on: [push, pull_request, release, workflow_dispatch]
4
5 jobs:
6 build_wheels:
7 name: Build wheels on ${{ matrix.os }}
8 runs-on: ${{ matrix.os }}
9 strategy:
10 matrix:
11 os: [ubuntu-latest, windows-latest, macos-latest]
12 steps:
13 - uses: actions/checkout@v4
14
15 - name: Set up MSVC x64
16 if: matrix.os == 'windows-latest'
17 uses: ilammy/msvc-dev-cmd@v1
18
19 - name: Set up QEMU
20 if: runner.os == 'Linux'
21 uses: docker/setup-qemu-action@v3
22 with:
23 platforms: all
24 # Temporary fix due to
25 # https://github.com/pypa/cibuildwheel/issues/2257
26 # https://github.com/docker/setup-qemu-action/issues/188
27 # https://github.com/tonistiigi/binfmt/issues/215
28 image: tonistiigi/binfmt:qemu-v8.1.5
29
30 - name: Build wheels
31 uses: pypa/[email protected]
32 env:
33 CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
34 CIBW_ARCHS_LINUX: "x86_64 i686 aarch64" # ppc64le s390x really slow
35 CIBW_ARCHS_WINDOWS: "AMD64" # ARM64 Seems ARM64 will rebuild amd64 wheel for unknow reason.
36 CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
37 CIBW_SKIP: ""
38 with:
39 package-dir: bindings/python
40
41 - uses: actions/upload-artifact@v4
42 with:
43 path: ./wheelhouse/*.whl
44 name: artifacts-${{ matrix.os }}
45
46 - name: Check binaries (Windows)
47 if: matrix.os == 'windows-latest'
48 run: |
49 python3.exe suite/check_wheel_bin_arch.py ./wheelhouse/
50
51 - name: Check binaries (Unix)
52 if: matrix.os != 'windows-latest'
53 run: |
54 ./suite/check_wheel_bin_arch.py ./wheelhouse/
55
56 make_sdist:
57 name: Make SDist
58 runs-on: ubuntu-latest
59 steps:
60 - uses: actions/checkout@v4
61 with:
62 fetch-depth: 0 # Optional, use if you use setuptools_scm
63 submodules: true # Optional, use if you have submodules
64
65 - name: Build SDist
66 run: |
67 cd bindings/python
68 pipx run build --sdist
69
70 - name: Test build with sdist
71 run: |
72 TMP_DIR=$(mktemp -d)
73 tar -xf bindings/python/dist/*.tar.gz -C $TMP_DIR/
74 cd $TMP_DIR/*/src
75 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -B build
76 cmake --build build
77
78 - uses: actions/upload-artifact@v4
79 with:
80 path: bindings/python/dist/*.tar.gz
81
82 publish:
83 needs: [build_wheels]
84 runs-on: ubuntu-latest
85 if: github.event_name == 'release' && github.event.prerelease == false && github.event.action == 'published'
86 permissions:
87 id-token: write
88 steps:
89 - uses: actions/download-artifact@v4
90 with:
91 merge-multiple: true
92 path: dist
93
94 - name: Show downloaded artifacts
95 run: ls -laR dist
96
97 - name: Publish distribution 📦 to PyPI
98 if: ${{ success() }}
99 uses: pypa/gh-action-pypi-publish@release/v1
100 with:
101 verbose: true
102 user: __token__
103 password: ${{ secrets.pypi_pass }}