Skip to content

Commit

Permalink
Fix build and release workflow (#5)
Browse files Browse the repository at this point in the history
* Add C_INCLUDE_PATH variable

* Add echo

* Pull proper MobilityDB branch

* Add checks and proper branch retrieval

* Fix branch check

* Add MACOSX_DEPLOYMENT_TARGET env variable
  • Loading branch information
Diviloper authored Aug 28, 2024
1 parent 4b49a91 commit 1ce8ba1
Showing 1 changed file with 98 additions and 4 deletions.
102 changes: 98 additions & 4 deletions .github/workflows/build_pymeos_cffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,96 @@ on:
- "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
Expand Down Expand Up @@ -37,6 +125,7 @@ jobs:

build_wheels:
name: Build PyMEOS CFFI for ${{ matrix.os }}
needs: checks
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -76,7 +165,7 @@ jobs:
- name: Install MEOS
if: runner.os == 'macOS'
run: |
git clone --depth 1 https://github.com/MobilityDB/MobilityDB
git clone --depth 1 --branch ${{ needs.checks.outputs.branch }} https://github.com/MobilityDB/MobilityDB
mkdir MobilityDB/build
cd MobilityDB/build
cmake .. -DMEOS=on
Expand All @@ -103,6 +192,7 @@ jobs:
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: |
Expand All @@ -116,7 +206,9 @@ jobs:
# 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
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 &&
Expand All @@ -127,7 +219,7 @@ jobs:
cmake ../json-c &&
make &&
make install &&
git clone --depth 1 https://github.com/MobilityDB/MobilityDB &&
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 &&
Expand Down Expand Up @@ -200,7 +292,7 @@ jobs:

create_release:
name: Create GitHub Release
needs: [ test_wheels, build_sdist ]
needs: [ checks, test_wheels, build_sdist ]
runs-on: ubuntu-22.04
steps:
- name: Get artifacts
Expand All @@ -213,3 +305,5 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: ./dist/*
prerelease: ${{ needs.checks.outputs.is_prerelease }}
generate_release_notes: true

0 comments on commit 1ce8ba1

Please sign in to comment.