Modernize CI build #86
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 | |
env: | |
GEOS_VERSION: "3.6.5" | |
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: Install build dependencies | |
run: | | |
python -m pip install build wheel | |
- name: Build package | |
run: | | |
cd packages/${{ matrix.package }} | |
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 wheels (${{ matrix.os }}) | |
needs: [build_data] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
before_all: | | |
echo "Starting BEFORE_ALL script" | |
cd "{package}" | |
export GEOS_DIR="$(pwd)/extern" | |
echo "GEOS_DIR set to: $GEOS_DIR" | |
python -c "import sys; sys.path.append('utils'); from GeosLibrary import GeosLibrary; GeosLibrary('3.6.5', root='extern').build('extern', njobs=16)" | |
# LD_LIBRARY_PATH in environment is needed by auditwheel. | |
environment: >- | |
GEOS_DIR="/project/packages/basemap/extern" | |
LD_LIBRARY_PATH="/project/packages/basemap/extern/lib" | |
PIP_DISABLE_PIP_VERSION_CHECK=1 | |
PIP_PREFER_BINARY=1 | |
PYTHONUNBUFFERED=1 | |
PYTHONWARNINGS="ignore:DEPRECATION" | |
- os: windows-latest | |
before_all: >- | |
pwsh -Command " | |
Write-Host 'Starting BEFORE_ALL script'; | |
$pwd = Get-Location; | |
Write-Host 'Current directory:' $pwd; | |
Set-Location '{package}'; | |
$env:GEOS_DIR = '{package}/extern'; | |
python -c 'import sys, os; sys.path.append(\"utils\"); from GeosLibrary import GeosLibrary; GeosLibrary(\"3.6.5\").build(\"extern\", njobs=16)' | |
" | |
environment: >- | |
GEOS_DIR="D:/a/basemap/basemap/packages/basemap/extern" | |
PIP_DISABLE_PIP_VERSION_CHECK=1 | |
PIP_PREFER_BINARY=1 | |
PYTHONUNBUFFERED=1 | |
PYTHONWARNINGS="ignore:DEPRECATION" | |
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: | | |
python -m pip install build | |
mkdir -p wheelhouse | |
cd packages/basemap | |
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 }} |