Build PyMEOS CFFI #7
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 PyMEOS CFFI | |
on: | |
create: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
jobs: | |
checks: | |
name: Make checks | |
runs-on: ubuntu-latest | |
outputs: | |
is_alpha: ${{ steps.check_alpha.outputs.is_alpha }} | |
is_beta: ${{ steps.check_beta.outputs.is_beta }} | |
is_rc: ${{ steps.check_rc.outputs.is_rc }} | |
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }} | |
branch: ${{ steps.check_branch.outputs.branch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if publishing an alpha version | |
id: check_alpha | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-alpha ]]; then | |
echo "Releasing an alpha version." | |
echo "is_alpha=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_alpha=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a beta version | |
id: check_beta | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]]; then | |
echo "Releasing a beta version." | |
echo "is_beta=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_beta=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a release candidate version | |
id: check_rc | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then | |
echo "Releasing an rc version." | |
echo "is_rc=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_rc=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check if publishing a prerelease version | |
id: check_prerelease | |
run: | | |
is_alpha=${{ steps.check_alpha.outputs.is_alpha }} | |
is_beta=${{ steps.check_beta.outputs.is_beta }} | |
is_rc=${{ steps.check_rc.outputs.is_rc }} | |
if [ "$is_alpha" == "true" ] || [ "$is_beta" == "true" ] || [ "$is_rc" == "true" ]; then | |
echo "Releasing an prerelease version." | |
echo "is_prerelease=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_prerelease=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check package version matches tag | |
run: | | |
tag_version=${GITHUB_REF#refs/tags/v} | |
python_version=$(grep -oP '__version__ = "\K[^"]+' pymeos_cffi/__init__.py) | |
if [[ "$tag_version" != "$python_version" ]]; then | |
echo "Tag Version ($tag_version) doesn't match Code Version ($python_version)" | |
echo "::error title=Version mismatch::Tag Version ($tag_version) doesn't match Code Version ($python_version)" | |
exit 1 | |
fi | |
- name: Check branch name | |
id: check_branch | |
run: | | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch=${raw##*/} | |
echo "branch=$branch" >> $GITHUB_OUTPUT | |
echo "Branch is $branch." | |
build_sdist: | |
name: Build PyMEOS CFFI source distribution | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
- name: Setup pip | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
- name: Build sdist | |
run: | | |
python -m build -s | |
ls -l dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pymeos_cffi-sdist | |
path: ./dist/pymeos_cffi-*.tar.gz | |
build_wheels: | |
name: Build PyMEOS CFFI for ${{ matrix.os }} | |
needs: checks | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-13, macos-14 ] | |
include: | |
- ld_prefix: "/usr/local" | |
- os: macos-14 | |
ld_prefix: "/opt/homebrew" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Update brew | |
if: matrix.os == 'macos-13' | |
# Necessary to avoid issue with macOS runners. See | |
# https://github.com/actions/runner-images/issues/4020 | |
run: | | |
brew reinstall [email protected] || brew link --overwrite [email protected] | |
brew reinstall [email protected] || brew link --overwrite [email protected] | |
brew update | |
- name: Get dependencies from homebrew (cache) | |
uses: tecolicom/actions-use-homebrew-tools@v1 | |
if: runner.os == 'macOS' | |
with: | |
tools: cmake libpq proj json-c gsl geos | |
- name: Get PROJ version | |
id: proj_version | |
if: runner.os == 'macOS' | |
run: | | |
proj_version=$(brew list --versions proj) | |
proj_version=${proj_version#* } | |
echo "proj_version=$proj_version" >> $GITHUB_OUTPUT | |
- name: Install MEOS | |
if: runner.os == 'macOS' | |
run: | | |
git clone --depth 1 --branch ${{ needs.checks.outputs.branch }} https://github.com/MobilityDB/MobilityDB | |
mkdir MobilityDB/build | |
cd MobilityDB/build | |
cmake .. -DMEOS=on | |
make -j | |
sudo make install | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
cache: "pip" | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel==2.20.0 | |
- name: Set PROJ_DATA (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
PROJ_DATA=${{ matrix.ld_prefix }}/Cellar/proj/${{ steps.proj_version.outputs.proj_version }}/share/proj | |
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV | |
- name: Set PROJ_DATA and JSON-C path (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
PROJ_DATA=/usr/proj81/share/proj | |
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64" >> $GITHUB_ENV | |
echo "C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/geos39/include/:/usr/proj81/include/" >> $GITHUB_ENV | |
- name: Build wheels | |
run: | | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib | |
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib | |
export PACKAGE_DATA=1 | |
python -m cibuildwheel --output-dir wheelhouse | |
env: | |
# Disable PyPy builds | |
# Disable builds on musllinux | |
# Disable builds in linux architectures other than x86_64 | |
CIBW_SKIP: "pp* *musllinux*" | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_ENVIRONMENT_PASS_LINUX: PACKAGE_DATA LD_LIBRARY_PATH PROJ_DATA C_INCLUDE_PATH | |
CIBW_ENVIRONMENT_MACOS: > | |
MACOSX_DEPLOYMENT_TARGET=14.0 | |
CIBW_BEFORE_ALL_LINUX: > | |
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm && | |
yum -y update && | |
yum -y install gcc gcc-c++ make cmake postgresql13-devel proj81-devel geos39-devel gsl-devel && | |
git clone --branch json-c-0.17 --depth 1 https://github.com/json-c/json-c && | |
mkdir json-c-build && | |
cd json-c-build && | |
cmake ../json-c && | |
make && | |
make install && | |
git clone --depth 1 --branch ${{ needs.checks.outputs.branch }} https://github.com/MobilityDB/MobilityDB && | |
mkdir MobilityDB/build && | |
cd MobilityDB/build && | |
cmake .. -DMEOS=on -DGEOS_INCLUDE_DIR=/usr/geos39/include/ -DGEOS_LIBRARY=/usr/geos39/lib64/libgeos_c.so -DGEOS_CONFIG=/usr/geos39/bin/geos-config -DPROJ_INCLUDE_DIRS=/usr/proj81/include/ -DPROJ_LIBRARIES=/usr/proj81/lib/libproj.so && | |
make -j && | |
make install | |
# Skip tests since they will be tested in the next job | |
CIBW_TEST_SKIP: "*" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pymeos_cffi-wheels-${{ matrix.os }} | |
path: ./wheelhouse/*.whl | |
test_wheels: | |
name: Test PyMEOS CFFI wheel - Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
needs: build_wheels | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] | |
os: [ ubuntu-latest, macos-13, macos-14 ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
name: pymeos_cffi-wheels-${{ matrix.os }} | |
path: ./pymeos_cffi_wheels | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install PyMEOS-CFFI wheels | |
run: | | |
python -m pip install --upgrade pip | |
pip install -f ./pymeos_cffi_wheels pymeos_cffi | |
- name: Run PyMEOS-CFFI check | |
run: | | |
python -c "import pymeos_cffi; print(pymeos_cffi.__version__);" | |
python -c "from pymeos_cffi import *; meos_initialize(None); print(tpoint_out(tgeompoint_in('POINT(2 3)@2000-01-01'), 3)); meos_finalize();" | |
upload_pypi: | |
name: Upload to PyPI | |
needs: [ test_wheels, build_sdist ] | |
runs-on: ubuntu-22.04 | |
if: github.repository == 'MobilityDB/PyMEOS-CFFI' | |
permissions: | |
id-token: write | |
steps: | |
- name: Get artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist | |
merge-multiple: true | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip_existing: true | |
create_release: | |
name: Create GitHub Release | |
needs: [ checks, test_wheels, build_sdist ] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist | |
merge-multiple: true | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./dist/* | |
prerelease: ${{ needs.checks.outputs.is_prerelease }} | |
generate_release_notes: true |