|
1 | | -name: Python Build |
| 1 | +name: Python tests, package build and publish on release |
2 | 2 |
|
3 | 3 | env: |
4 | 4 | # Set to avoid errors when building FFTW with CMake v4+ |
5 | 5 | # https://github.com/FFTW/fftw3/issues/381 |
6 | 6 | CMAKE_POLICY_VERSION_MINIMUM: 3.5 |
7 | 7 |
|
8 | | -"on": |
| 8 | +on: |
9 | 9 | push: |
10 | 10 | branches: ["main"] |
11 | | - tags: |
12 | | - - "v[0-9]+.[0-9]+.[0-9]+" |
13 | | - - "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" |
14 | 11 | pull_request: |
| 12 | + release: |
| 13 | + types: |
| 14 | + - published |
15 | 15 |
|
16 | 16 | jobs: |
17 | | - from-sdist: |
18 | | - name: python source distribution |
19 | | - runs-on: ubuntu-latest |
| 17 | + tests: |
| 18 | + name: Run tests on ${{matrix.os}} / Python ${{matrix.python-version}} |
| 19 | + runs-on: ${{matrix.os}} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: [macos-latest, ubuntu-latest] |
| 24 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
20 | 25 | steps: |
21 | 26 | - uses: actions/checkout@v4 |
22 | | - - name: Set up Python 3.8 |
| 27 | + - name: Set up Python |
23 | 28 | uses: actions/setup-python@v5 |
24 | 29 | with: |
25 | | - python-version: 3.8 |
26 | | - |
27 | | - - name: Install build packages and pytest |
28 | | - run: | |
29 | | - python -m pip install --upgrade pip wheel setuptools |
30 | | - python -m pip install "conan<2" scikit-build pytest cython numpy |
31 | | -
|
32 | | - - name: Create sdist |
33 | | - run: python setup.py sdist |
34 | | - |
35 | | - - name: Install python so3 |
36 | | - run: "pip install dist/so3-*.tar.gz" |
37 | | - |
| 30 | + python-version: ${{matrix.python-version}} |
| 31 | + - name: Install so3 |
| 32 | + run: pip install ".[dev]" |
38 | 33 | - name: run pytest |
39 | 34 | run: pytest tests/ |
40 | 35 |
|
| 36 | + |
| 37 | + build-sdist: |
| 38 | + name: Build source distribution |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + - name: Set up Python |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: 3.x |
| 46 | + - name: Upgrade pip and install build |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip |
| 49 | + python -m pip install build |
| 50 | + - name: Build sdist |
| 51 | + run: python -m build --sdist |
41 | 52 | - uses: actions/upload-artifact@v4 |
42 | | - if: ${{ startsWith(github.ref, 'refs/tags') }} |
43 | 53 | with: |
44 | | - path: ./dist/*.tar.gz |
45 | | - name: source-distribution |
| 54 | + name: pkg-sdist |
| 55 | + path: dist/*.tar.gz |
46 | 56 |
|
47 | 57 |
|
48 | | - build_wheels: |
49 | | - name: Build wheels on ${{ matrix.os }} |
50 | | - runs-on: ${{ matrix.os }} |
| 58 | + build-wheels: |
| 59 | + name: Build wheels on ${{matrix.os}} / Python ${{matrix.python-version}} |
| 60 | + runs-on: ${{matrix.os}} |
51 | 61 | strategy: |
| 62 | + fail-fast: false |
52 | 63 | matrix: |
53 | | - os: [macos-latest] |
54 | | - python-version: [3.8] |
| 64 | + os: [macos-latest, ubuntu-latest] |
| 65 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
55 | 66 |
|
56 | 67 | steps: |
57 | 68 | - uses: actions/checkout@v4 |
58 | | - |
59 | 69 | - uses: actions/setup-python@v4 |
60 | | - name: Install Python |
| 70 | + name: Set up Python |
61 | 71 | with: |
62 | 72 | python-version: ${{ matrix.python-version }} |
63 | | - |
64 | | - - name: Setup environment |
| 73 | + - name: Upgrade pip and install build |
65 | 74 | run: | |
66 | | - python -m pip install --upgrade pip wheel |
67 | | - python -m pip install "conan<2" pytest |
68 | | - conan profile new default --detect |
69 | | -
|
70 | | - - name: Build wheels |
71 | | - run: pip wheel . --use-pep517 --no-deps -w dist |
72 | | - |
73 | | - - name: install wheel |
74 | | - run: "pip install dist/*.whl" |
75 | | - |
76 | | - - name: run pytests |
77 | | - run: pytest tests |
78 | | - |
| 75 | + python -m pip install --upgrade pip |
| 76 | + python -m pip install build |
| 77 | + - name: Build sdist |
| 78 | + run: python -m build --wheel |
79 | 79 | - uses: actions/upload-artifact@v4 |
80 | | - if: ${{ startsWith(github.ref, 'refs/tags') }} |
81 | 80 | with: |
82 | | - path: ./dist/*.whl |
83 | | - name: wheel-${{matrix.os}}-${{matrix.python-version}} |
| 81 | + name: pkg-wheel-${{matrix.os}}-python-${{matrix.python-version}} |
| 82 | + path: dist/*.whl |
84 | 83 |
|
85 | | - publication: |
86 | | - name: publish to pypi |
87 | | - if: ${{ startsWith(github.ref, 'refs/tags') }} |
| 84 | + publish: |
| 85 | + name: Publish to PyPI |
| 86 | + if: github.event_name == 'release' && github.event.action == 'published' |
88 | 87 | runs-on: ubuntu-latest |
89 | | - needs: [build_wheels, from-sdist] |
| 88 | + needs: [build-wheels, build-sdist] |
90 | 89 | steps: |
91 | 90 | - name: Download wheels and sdist |
92 | 91 | uses: actions/download-artifact@v4 |
93 | | - |
94 | | - - name: Move wheels and source distribution to dist/ |
95 | | - run: | |
96 | | - mkdir -p dist |
97 | | - mv source-distribution/*.tar.gz wheel-*/*.whl dist |
98 | | -
|
| 92 | + with: |
| 93 | + pattern: pkg-* |
| 94 | + path: dist |
| 95 | + merge-multiple: true |
99 | 96 | - name: Publish distribution 📦 to Test PyPI |
100 | | - if: ${{ github.ref != 'refs/tags/v1.3.6' }} |
101 | 97 | uses: pypa/gh-action-pypi-publish@release/v1 |
102 | 98 | with: |
103 | 99 | password: ${{ secrets.TEST_PYPI_TOKEN }} |
104 | | - repository_url: https://test.pypi.org/legacy/ |
105 | | - |
| 100 | + repository-url: https://test.pypi.org/legacy/ |
106 | 101 | - name: Publish distribution 📦 to PyPI |
107 | | - if: ${{ github.ref == 'refs/tags/v1.3.6' }} |
108 | 102 | uses: pypa/gh-action-pypi-publish@release/v1 |
109 | 103 | with: |
110 | 104 | password: ${{ secrets.PYPI_TOKEN }} |
0 commit comments