|
1 | | -name: python |
| 1 | +name: Python Build |
2 | 2 |
|
3 | | -on: |
| 3 | +"on": |
4 | 4 | push: |
5 | | - branches: ["main"] |
| 5 | + branches: ["main"] |
| 6 | + tags: |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 8 | + - "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" |
6 | 9 | pull_request: |
7 | 10 |
|
8 | 11 | jobs: |
9 | | - testing: |
| 12 | + development-mode: |
| 13 | + name: pip development mode on ${{ matrix.os }} |
10 | 14 | runs-on: ${{ matrix.os }} |
11 | 15 | strategy: |
12 | 16 | fail-fast: false |
13 | 17 | matrix: |
14 | | - os: [ubuntu-latest, macos-latest] |
| 18 | + os: [macos-latest] |
15 | 19 | python-version: [3.8] |
16 | 20 |
|
17 | 21 | steps: |
18 | | - - uses: actions/checkout@v2 |
19 | | - - name: Set up Python ${{ matrix.python-version }} |
20 | | - uses: actions/setup-python@v2 |
21 | | - with: |
22 | | - python-version: ${{ matrix.python-version }} |
23 | | - |
24 | | - - name: Install build packages |
25 | | - run: python -m pip install --upgrade pip scikit-build |
26 | | - |
27 | | - - name: Create sdist package |
28 | | - run: python setup.py sdist |
29 | | - |
30 | | - - name: Install pys2let |
31 | | - run: pip install dist/pys2let-2.1.0.tar.gz |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + - name: Set up Python ${{ matrix.python-version }} |
| 24 | + uses: actions/setup-python@v2 |
| 25 | + with: |
| 26 | + python-version: ${{ matrix.python-version }} |
| 27 | + |
| 28 | + - name: Install build packages and pytest |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip wheel |
| 31 | + python -m pip install scikit-build |
| 32 | +
|
| 33 | + - name: Install python s2let |
| 34 | + run: pip install -e .[dev] |
| 35 | + |
| 36 | + - name: run pytest |
| 37 | + run: pytest src/test/python/ |
| 38 | + |
| 39 | + from-sdist: |
| 40 | + name: python source distribution |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - name: Set up Python 3.8 |
| 45 | + uses: actions/setup-python@v2 |
| 46 | + with: |
| 47 | + python-version: 3.8 |
| 48 | + |
| 49 | + - name: Install build packages and pytest |
| 50 | + run: | |
| 51 | + python -m pip install --upgrade pip wheel setuptools |
| 52 | + python -m pip install conan scikit-build pytest cython numpy |
| 53 | +
|
| 54 | + - name: Create sdist |
| 55 | + run: python setup.py sdist |
| 56 | + |
| 57 | + - name: Install python s2let |
| 58 | + run: "pip install dist/pys2let-*.tar.gz" |
| 59 | + |
| 60 | + - name: run pytest |
| 61 | + run: pytest src/test/python/ |
| 62 | + |
| 63 | + - uses: actions/upload-artifact@v2 |
| 64 | + if: ${{ startsWith(github.ref, 'refs/tags') }} |
| 65 | + with: |
| 66 | + path: ./dist/*.tar.gz |
| 67 | + name: source-distribution |
| 68 | + |
| 69 | + |
| 70 | + build_wheels: |
| 71 | + name: Build wheels on ${{ matrix.os }} |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + os: [macos-latest] |
| 76 | + python-version: [3.8] |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + |
| 81 | + - uses: actions/setup-python@v2 |
| 82 | + name: Install Python |
| 83 | + with: |
| 84 | + python-version: ${{ matrix.python-version }} |
| 85 | + |
| 86 | + - name: Setup environment |
| 87 | + run: | |
| 88 | + python -m pip install --upgrade pip wheel |
| 89 | + python -m pip install conan pytest |
| 90 | + conan profile new default --detect |
| 91 | +
|
| 92 | + - name: Build wheels |
| 93 | + run: pip wheel . --use-pep517 --no-deps -w dist |
| 94 | + |
| 95 | + - name: install wheel |
| 96 | + run: "pip install dist/*.whl" |
| 97 | + |
| 98 | + - name: run pytests |
| 99 | + run: pytest src/test/python/ |
| 100 | + |
| 101 | + - uses: actions/upload-artifact@v2 |
| 102 | + if: ${{ startsWith(github.ref, 'refs/tags') }} |
| 103 | + with: |
| 104 | + path: ./dist/*.whl |
| 105 | + name: wheel-${{matrix.os}}-${{matrix.python-version}} |
| 106 | + |
| 107 | + publication: |
| 108 | + name: publish to pypi |
| 109 | + if: ${{ startsWith(github.ref, 'refs/tags') }} |
| 110 | + runs-on: ubuntu-latest |
| 111 | + needs: [build_wheels, from-sdist] |
| 112 | + steps: |
| 113 | + - name: Download wheels and sdist |
| 114 | + uses: actions/download-artifact@v2 |
| 115 | + |
| 116 | + - name: Move wheels and source distribution to dist/ |
| 117 | + run: | |
| 118 | + mkdir -p dist |
| 119 | + mv source-distribution/*.tar.gz wheel-*/*.whl dist |
| 120 | +
|
| 121 | + - name: Publish distribution 📦 to Test PyPI |
| 122 | + if: ${{ github.ref != 'refs/tags/v2.1.0' }} |
| 123 | + uses: pypa/gh-action-pypi-publish@master |
| 124 | + with: |
| 125 | + password: ${{ secrets.TEST_PYPI_TOKEN }} |
| 126 | + repository_url: https://test.pypi.org/legacy/ |
| 127 | + |
| 128 | + - name: Publish distribution 📦 to PyPI |
| 129 | + if: ${{ github.ref == 'refs/tags/v2.1.0' }} |
| 130 | + uses: pypa/gh-action-pypi-publish@master |
| 131 | + with: |
| 132 | + password: ${{ secrets.PYPI_TOKEN }} |
0 commit comments