|
1 |
| -name: Publish python PyPI |
| 1 | +name: Publish to PyPI |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | tags:
|
6 | 6 | - v*
|
7 | 7 |
|
8 | 8 | 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] |
12 | 16 | steps:
|
13 | 17 | - uses: actions/checkout@v3
|
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v4 |
14 | 21 | 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 | + |
16 | 51 | - name: Set up Python
|
17 |
| - uses: actions/setup-python@v3 |
| 52 | + uses: actions/setup-python@v4 |
18 | 53 | with:
|
19 |
| - python-version: '3.10' |
| 54 | + python-version: "3.12" |
20 | 55 |
|
21 |
| - - name: Install build tools |
| 56 | + - name: Upgrade pip and install build |
22 | 57 | 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 |
24 | 82 |
|
25 |
| - - name: Build Package |
| 83 | + - name: Merge all distributions |
26 | 84 | 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/ \; |
28 | 88 |
|
29 |
| - - name: Publish package to PyPI |
| 89 | + - name: Publish to PyPI |
30 | 90 | uses: pypa/gh-action-pypi-publish@release/v1
|
31 | 91 | with:
|
32 | 92 | password: ${{ secrets.PYPI_API_TOKEN }}
|
| 93 | + packages_dir: final_dist |
0 commit comments