|
1 | | -# A simple workflow to build a Python sdist and wheel on Windows. |
2 | | -# This file should be placed in the .github/workflows/ directory of your repository. |
3 | | - |
4 | | -name: Build Python Package |
| 1 | +name: Build and Publish macOS Wheels |
5 | 2 |
|
6 | 3 | on: |
7 | | - # Triggers the workflow on push or pull request events for the "main" branch |
| 4 | + release: |
| 5 | + types: [created] |
8 | 6 | push: |
9 | 7 | branches: [ "main" ] |
10 | 8 | pull_request: |
11 | 9 | branches: [ "main" ] |
12 | 10 |
|
13 | | - # Allows you to run this workflow manually from the Actions tab |
14 | 11 | workflow_dispatch: |
15 | 12 |
|
16 | 13 | jobs: |
17 | | - build: |
18 | | - # The type of runner that the job will run on |
| 14 | + build_wheels: |
| 15 | + name: Build wheels for macOS (arm64) |
19 | 16 | runs-on: macos-latest |
20 | 17 |
|
21 | 18 | steps: |
22 | | - # Step 1: Check out your repository code so the workflow can access it |
23 | 19 | - name: Checkout code |
24 | 20 | uses: actions/checkout@v4 |
25 | | - |
26 | | - # Step 2: Set up a Python environment |
27 | | - - name: Set up Python 3.11 |
28 | | - uses: actions/setup-python@v5 |
29 | 21 | with: |
30 | | - python-version: '3.11' |
31 | | - architecture: 'arm64' |
32 | | - |
33 | | - - uses: tecolicom/actions-install-and-cache@v1 |
| 22 | + # Required for cibuildwheel to get a clean version number. |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Build wheels |
| 26 | + uses: pypa/cibuildwheel@v2.19.2 |
| 27 | + env: |
| 28 | + # Python versions to build for. |
| 29 | + CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*" |
| 30 | + CIBW_ARCHS_MACOS: arm64 |
| 31 | + CIBW_BEFORE_BUILD: "brew install sdl2 opencv pybind11" |
| 32 | + |
| 33 | + - name: Store wheels as artifact |
| 34 | + uses: actions/upload-artifact@v4 |
34 | 35 | with: |
35 | | - run: brew install sdl2 opencv pybind11 |
36 | | - path: /usr/local |
37 | | - verbose: true |
| 36 | + name: macos-wheels |
| 37 | + path: ./wheelhouse/*.whl |
38 | 38 |
|
39 | | - # Step 6: Install the 'build' package itself, which is required to run the build command |
40 | | - - name: Install build tool |
41 | | - run: python -m pip install --upgrade build |
| 39 | + publish_to_pypi: |
| 40 | + name: Publish wheels to PyPI |
| 41 | + needs: build_wheels |
| 42 | + runs-on: ubuntu-latest |
| 43 | + # if: github.event_name == 'release' && github.event.action == 'created' |
42 | 44 |
|
43 | | - # Step 7: Run the build command as requested |
44 | | - - name: Build sdist and wheel |
45 | | - run: python -m build -v -sw |
| 45 | + steps: |
| 46 | + - name: Download wheels from artifact |
| 47 | + uses: actions/download-artifact@v4 |
| 48 | + with: |
| 49 | + name: macos-wheels |
| 50 | + path: dist |
| 51 | + |
| 52 | + - name: Publish package to PyPI |
| 53 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 54 | + with: |
| 55 | + password: ${{ secrets.PYPI_API_TOKEN }} |
46 | 56 |
|
0 commit comments