Modernize CI build #91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
paths: | |
- ".github/workflows/**" | |
- "packages/basemap/**" | |
- "packages/basemap_data/**" | |
- "packages/basemap_data_hires/**" | |
pull_request: | |
paths: | |
- ".github/workflows/**" | |
- "packages/basemap/**" | |
- "packages/basemap_data/**" | |
- "packages/basemap_data_hires/**" | |
workflow_dispatch: | |
jobs: | |
build_data: | |
name: Build data packages | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: [basemap_data, basemap_data_hires] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Build sdist and wheels | |
run: | | |
cd packages/${{ matrix.package }} | |
python -m pip install build wheel | |
python -m build --sdist --wheel | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: packages/${{ matrix.package }}/dist/* | |
name: dist-${{ matrix.package }} | |
build_basemap: | |
name: Build basemap package (${{ matrix.os }}) | |
needs: [build_data] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
before_all: | | |
echo "Starting BEFORE_ALL script" | |
echo "GEOS_DIR set to: ${GEOS_DIR}" | |
cd "{package}" | |
python -c "import utils; utils.GeosLibrary('${GEOS_VERSION}').build('${GEOS_DIR}', njobs=2)" | |
# LD_LIBRARY_PATH in environment is needed by auditwheel. | |
environment: >- | |
GEOS_VERSION="3.6.5" | |
GEOS_DIR="/project/packages/basemap/extern" | |
LD_LIBRARY_PATH="/project/packages/basemap/extern/lib" | |
PIP_PREFER_BINARY=1 | |
PYTHONUNBUFFERED=1 | |
- os: windows-latest | |
before_all: | | |
Write-Host "Starting BEFORE_ALL script" | |
Write-Host "GEOS_DIR set to: ${env:GEOS_DIR}" | |
Set-Location "{package}" | |
python -c "import utils; utils.GeosLibrary('${env:GEOS_VERSION}').build('${env:GEOS_DIR}', njobs=2)" | |
environment: >- | |
GEOS_VERSION="3.6.5" | |
GEOS_DIR="D:/a/basemap/basemap/packages/basemap/extern" | |
PIP_PREFER_BINARY=1 | |
PYTHONUNBUFFERED=1 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Build sdist | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
mkdir -p wheelhouse | |
cd packages/basemap | |
python -m pip install build | |
python -m build --sdist | |
mv dist/* ../../wheelhouse/ | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.22.0 | |
env: | |
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" | |
CIBW_ARCHS_LINUX: auto64 | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_BUILD: "cp39* cp310* cp311* cp312*" | |
CIBW_SKIP: "pp* *-musllinux_* *-win32 *-manylinux_i686 *-musllinux_i686 *-aarch64 *-armv7l" | |
CIBW_BEFORE_ALL: ${{ matrix.before_all }} | |
CIBW_ENVIRONMENT: ${{ matrix.environment }} | |
CIBW_BUILD_REQUIRES: "cython>=0.29,<3.1" | |
with: | |
package-dir: packages/basemap | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
./wheelhouse/*.whl | |
./wheelhouse/*.tar.gz | |
name: wheels-basemap-${{ matrix.os }} | |
upload_pypi: | |
needs: [build_data, build_basemap] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
strategy: | |
matrix: | |
package: [basemap, basemap_data, basemap_data_hires] | |
include: | |
- package: basemap | |
artifact_pattern: "wheels-basemap-*" | |
- package: basemap_data | |
artifact_pattern: "dist-basemap_data" | |
- package: basemap_data_hires | |
artifact_pattern: "dist-basemap_data_hires" | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: ${{ matrix.artifact_pattern }} | |
path: dist | |
merge-multiple: true | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} |