|
1 | | -name: publish |
2 | | -on: |
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +on: |
3 | 4 | push: |
4 | | - tags: |
5 | | - - v1.* |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + types: |
| 8 | + - published |
6 | 9 |
|
7 | 10 | jobs: |
8 | | - sdist: |
9 | | - runs-on: windows-2019 |
| 11 | + build_wheels: |
| 12 | + name: Build wheels |
| 13 | + runs-on: windows-2022 |
| 14 | + |
10 | 15 | steps: |
11 | 16 | - uses: actions/checkout@v3 |
12 | | - - run: python -m pip install build |
13 | | - - run: python -m build --sdist |
| 17 | + |
| 18 | + - name: Build wheels |
| 19 | + uses: pypa/cibuildwheel@v2.12.1 |
| 20 | + |
14 | 21 | - uses: actions/upload-artifact@v3 |
15 | 22 | with: |
16 | | - name: sdist_${{ github.run_id }} |
17 | | - path: dist/ |
18 | | - |
19 | | - bdist: |
20 | | - runs-on: windows-2019 |
21 | | - strategy: |
22 | | - matrix: |
23 | | - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] |
24 | | - architecture: ['x86', 'x64'] |
25 | | - name: Python ${{ matrix.python-version }} ${{ matrix.architecture }} bdist |
| 23 | + path: ./wheelhouse/*.whl |
| 24 | + |
| 25 | + build_sdist: |
| 26 | + name: Build source distribution |
| 27 | + runs-on: ubuntu-latest |
26 | 28 | steps: |
27 | 29 | - uses: actions/checkout@v3 |
28 | | - - uses: actions/setup-python@v4 |
29 | | - with: |
30 | | - python-version: ${{ matrix.python-version }} |
31 | | - architecture: ${{ matrix.architecture }} |
32 | | - - run: python -m pip install build |
33 | | - - name: Run python -m build --wheel |
34 | | - run: | |
35 | | - Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" |
36 | | - Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" -DevCmdArguments '-arch=${{ matrix.architecture }}' |
37 | | - python -m build --wheel |
| 30 | + |
| 31 | + - name: Build sdist |
| 32 | + run: pipx run build --sdist |
| 33 | + |
38 | 34 | - uses: actions/upload-artifact@v3 |
39 | 35 | with: |
40 | | - name: bdist_${{ matrix.python-version }}_${{ matrix.architecture }}_${{ github.run_id }} |
41 | | - path: dist/ |
| 36 | + path: dist/*.tar.gz |
42 | 37 |
|
43 | | - publish: |
44 | | - needs: [sdist, bdist] |
45 | | - runs-on: ubuntu-20.04 |
| 38 | + upload_pypi: |
| 39 | + needs: [build_wheels, build_sdist] |
| 40 | + runs-on: ubuntu-latest |
| 41 | + if: github.event_name == 'release' && github.event.action == 'published' |
46 | 42 | steps: |
47 | 43 | - uses: actions/download-artifact@v3 |
48 | 44 | with: |
49 | | - path: artifacts |
50 | | - - run: | |
51 | | - mkdir -p dist |
52 | | - mv artifacts/{b,s}dist_*/* dist/ |
53 | | - - uses: pypa/gh-action-pypi-publish@release/v1 |
| 45 | + name: artifact |
| 46 | + path: dist |
| 47 | + |
| 48 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
54 | 49 | with: |
55 | 50 | user: __token__ |
56 | 51 | password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments