|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +env: |
| 4 | + PKGDIR: "packages/basemap" |
| 5 | + CIBW_BUILD_VERBOSITY: 1 |
| 6 | + PYTHONUNBUFFERED: "1" |
| 7 | + PYTHONWARNINGS: "ignore:DEPRECATION" |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + paths: |
| 12 | + - ".github/workflows/**" |
| 13 | + - "packages/basemap/**" |
| 14 | + - "packages/basemap_data/**" |
| 15 | + - "packages/basemap_data_hires/**" |
| 16 | + pull_request: |
| 17 | + paths: |
| 18 | + - ".github/workflows/**" |
| 19 | + - "packages/basemap/**" |
| 20 | + - "packages/basemap_data/**" |
| 21 | + - "packages/basemap_data_hires/**" |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +jobs: |
| 25 | + build_wheels: |
| 26 | + name: Build wheels on ${{ matrix.os }} |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + os: [ubuntu-20.04, windows-2019, macos-11] |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v4 |
| 37 | + with: |
| 38 | + python-version: "3.9" |
| 39 | + |
| 40 | + - name: Install cibuildwheel |
| 41 | + run: python -m pip install cibuildwheel==2.16.2 |
| 42 | + |
| 43 | + - name: Build wheels |
| 44 | + env: |
| 45 | + CIBW_SKIP: "pp* *-musllinux*" # Skip PyPy and musllinux |
| 46 | + CIBW_BEFORE_BUILD: > |
| 47 | + pip install numpy cython && |
| 48 | + python -c "import utils; utils.GeosLibrary('3.6.5').build('extern', njobs=16)" |
| 49 | + CIBW_BEFORE_TEST: "pip install -r {project}/requirements-test.txt" |
| 50 | + CIBW_TEST_COMMAND: > |
| 51 | + cd {project} && python -m pytest --cov="mpl_toolkits.basemap" |
| 52 | + --cov-report=term --ignore=dist --ignore=build |
| 53 | + CIBW_BUILD: "cp27-* cp35-* cp36-* cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*" |
| 54 | + CIBW_ENVIRONMENT: "GEOS_DIR={project}/extern" |
| 55 | + run: | |
| 56 | + cd ${{ env.PKGDIR }} |
| 57 | + python -m cibuildwheel --output-dir wheelhouse |
| 58 | +
|
| 59 | + - uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: wheels-${{ matrix.os }} |
| 62 | + path: ${{ env.PKGDIR }}/wheelhouse/*.whl |
| 63 | + |
| 64 | + build_sdist: |
| 65 | + name: Build source distribution |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Set up Python |
| 71 | + uses: actions/setup-python@v4 |
| 72 | + with: |
| 73 | + python-version: "3.9" |
| 74 | + |
| 75 | + - name: Build sdist |
| 76 | + run: | |
| 77 | + cd ${{ env.PKGDIR }} |
| 78 | + pip install build |
| 79 | + python -m build --sdist |
| 80 | +
|
| 81 | + - uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: sdist |
| 84 | + path: ${{ env.PKGDIR }}/dist/*.tar.gz |
| 85 | + |
| 86 | + upload_testpypi: |
| 87 | + needs: [build_wheels, build_sdist] |
| 88 | + runs-on: ubuntu-latest |
| 89 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 90 | + environment: |
| 91 | + name: TestPyPI |
| 92 | + url: https://test.pypi.org/p/basemap |
| 93 | + permissions: |
| 94 | + id-token: write |
| 95 | + steps: |
| 96 | + - uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + pattern: wheels-* |
| 99 | + path: dist |
| 100 | + merge-multiple: true |
| 101 | + |
| 102 | + - uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: sdist |
| 105 | + path: dist |
| 106 | + |
| 107 | + - name: Upload to TestPyPI |
| 108 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 109 | + with: |
| 110 | + repository-url: https://test.pypi.org/legacy/ |
| 111 | + |
| 112 | + upload_pypi: |
| 113 | + needs: [build_wheels, build_sdist, upload_testpypi] |
| 114 | + runs-on: ubuntu-latest |
| 115 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 116 | + environment: |
| 117 | + name: PyPI |
| 118 | + url: https://pypi.org/p/basemap |
| 119 | + permissions: |
| 120 | + id-token: write |
| 121 | + steps: |
| 122 | + - uses: actions/download-artifact@v4 |
| 123 | + with: |
| 124 | + pattern: wheels-* |
| 125 | + path: dist |
| 126 | + merge-multiple: true |
| 127 | + |
| 128 | + - uses: actions/download-artifact@v4 |
| 129 | + with: |
| 130 | + name: sdist |
| 131 | + path: dist |
| 132 | + |
| 133 | + - name: Upload to PyPI |
| 134 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments