Skip to content

Commit 3eadb4d

Browse files
committed
Fix test workflow and add release workflow
1 parent 07873e9 commit 3eadb4d

File tree

2 files changed

+163
-6
lines changed

2 files changed

+163
-6
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Release and Publish PyMEOS
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
checks:
10+
name: Make checks
11+
runs-on: ubuntu-latest
12+
13+
outputs:
14+
is_alpha: ${{ steps.check_alpha.outputs.is_alpha }}
15+
is_beta: ${{ steps.check_beta.outputs.is_beta }}
16+
is_rc: ${{ steps.check_rc.outputs.is_rc }}
17+
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Check if publishing an alpha version
24+
id: check_alpha
25+
run: |
26+
VERSION=${GITHUB_REF#refs/tags/}
27+
28+
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-alpha ]]; then
29+
echo "Releasing an alpha version."
30+
echo "is_alpha=true" >> "$GITHUB_OUTPUT"
31+
else
32+
echo "is_alpha=false" >> "$GITHUB_OUTPUT"
33+
fi
34+
35+
- name: Check if publishing a beta version
36+
id: check_beta
37+
run: |
38+
VERSION=${GITHUB_REF#refs/tags/}
39+
40+
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]]; then
41+
echo "Releasing a beta version."
42+
echo "is_beta=true" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "is_beta=false" >> "$GITHUB_OUTPUT"
45+
fi
46+
47+
- name: Check if publishing a release candidate version
48+
id: check_rc
49+
run: |
50+
VERSION=${GITHUB_REF#refs/tags/}
51+
52+
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then
53+
echo "Releasing an rc version."
54+
echo "is_rc=true" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "is_rc=false" >> "$GITHUB_OUTPUT"
57+
fi
58+
59+
- name: Check if publishing a prerelease version
60+
id: check_prerelease
61+
run: |
62+
is_alpha=${{ steps.check_alpha.outputs.is_alpha }}
63+
is_beta=${{ steps.check_beta.outputs.is_beta }}
64+
is_rc=${{ steps.check_rc.outputs.is_rc }}
65+
66+
if [ "$is_alpha" == "true" ] || [ "$is_beta" == "true" ] || [ "$is_rc" == "true" ]; then
67+
echo "Releasing an prerelease version."
68+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
69+
else
70+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
71+
fi
72+
73+
- name: Check package version matches tag
74+
run: |
75+
tag_version=${GITHUB_REF#refs/tags/v}
76+
python_version=$(grep -oP '__version__ = "\K[^"]+' pymeos/__init__.py)
77+
78+
if [[ "$tag_version" != "$python_version" ]]; then
79+
echo "Tag Version ($tag_version) doesn't match Code Version ($python_version)"
80+
echo "::error title=Version mismatch::Tag Version ($tag_version) doesn't match Code Version ($python_version)"
81+
exit 1
82+
fi
83+
84+
85+
build:
86+
name: Build PyMEOS
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@v3
95+
with:
96+
python-version: 3.8
97+
cache: "pip"
98+
99+
- name: Setup pip
100+
run: |
101+
python -m pip install --upgrade pip
102+
python -m pip install build
103+
104+
- name: Build package
105+
run: python -m build
106+
107+
- name: Upload artifacts
108+
uses: actions/upload-artifact@v4
109+
with:
110+
path: |
111+
./dist/pymeos-*.tar.gz
112+
./dist/pymeos-*.whl
113+
114+
release:
115+
name: Create GitHub Release
116+
runs-on: ubuntu-latest
117+
needs: [ checks, build ]
118+
119+
permissions:
120+
contents: write
121+
122+
steps:
123+
- name: Get artifacts
124+
uses: actions/download-artifact@v4
125+
with:
126+
path: ./dist
127+
merge-multiple: true
128+
129+
- name: Create Release
130+
uses: softprops/action-gh-release@v2
131+
with:
132+
files: ./dist/*
133+
prerelease: ${{ needs.checks.outputs.is_prerelease }}
134+
generate_release_notes: true
135+
136+
publish:
137+
name: Upload to PyPI
138+
needs: [ build ]
139+
runs-on: ubuntu-latest
140+
141+
if: github.repository == 'MobilityDB/PyMEOS'
142+
environment:
143+
name: pypi
144+
url: https://pypi.org/p/pymeos
145+
permissions:
146+
id-token: write
147+
148+
steps:
149+
- name: Get artifacts
150+
uses: actions/download-artifact@v4
151+
with:
152+
path: ./dist
153+
merge-multiple: true
154+
155+
- name: Publish to PyPI
156+
uses: pypa/gh-action-pypi-publish@release/v1
157+

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
26+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
2727
os: [ ubuntu-latest, macos-13, macos-14 ]
2828
include:
29-
- ld_path: "/usr/local/lib"
29+
- ld_prefix: "/usr/local"
3030
- os: macos-14
31-
ld_path: "/opt/homebrew/lib"
31+
ld_prefix: "/opt/homebrew"
3232

3333
steps:
3434
- name: Checkout
@@ -66,7 +66,7 @@ jobs:
6666
run: |
6767
mkdir MobilityDB/build
6868
cd MobilityDB/build
69-
cmake .. -DMEOS=on
69+
cmake .. -DMEOS=on -DCMAKE_INSTALL_PREFIX=${{ matrix.ld_prefix }}
7070
make -j
7171
sudo make install
7272
@@ -97,6 +97,6 @@ jobs:
9797
9898
- name: Test PyMEOS with pytest
9999
run: |
100-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }}
101-
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }}
100+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
101+
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
102102
pytest

0 commit comments

Comments
 (0)