Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test workflow and add release workflow #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions .github/workflows/release_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Release and Publish PyMEOS

on:
push:
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 }}

steps:
- name: Checkout
uses: actions/checkout@v4

- 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/__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


build:
name: Build PyMEOS
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8
cache: "pip"

- name: Setup pip
run: |
python -m pip install --upgrade pip
python -m pip install build

- name: Build package
run: python -m build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: |
./dist/pymeos-*.tar.gz
./dist/pymeos-*.whl

release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [ checks, build ]

permissions:
contents: write

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

publish:
name: Upload to PyPI
needs: [ build ]
runs-on: ubuntu-latest

if: github.repository == 'MobilityDB/PyMEOS'
environment:
name: pypi
url: https://pypi.org/p/pymeos
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

12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
os: [ ubuntu-latest, macos-13, macos-14 ]
include:
- ld_path: "/usr/local/lib"
- ld_prefix: "/usr/local"
- os: macos-14
ld_path: "/opt/homebrew/lib"
ld_prefix: "/opt/homebrew"

steps:
- name: Checkout
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
run: |
mkdir MobilityDB/build
cd MobilityDB/build
cmake .. -DMEOS=on
cmake .. -DMEOS=on -DCMAKE_INSTALL_PREFIX=${{ matrix.ld_prefix }}
make -j
sudo make install

Expand Down Expand Up @@ -97,6 +97,6 @@ jobs:

- name: Test PyMEOS with pytest
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }}
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
pytest
Loading