-
Notifications
You must be signed in to change notification settings - Fork 17
72 lines (64 loc) · 2.59 KB
/
version-check.yml
File metadata and controls
72 lines (64 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Version Check
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests packaging
- name: Check version against PyPI
run: |
python - <<EOF
import requests
import sys
import re
from packaging import version
# Read version from version.py
with open("src/version.py", "r") as f:
version_content = f.read()
# Extract version string from file
version_match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', version_content)
if not version_match:
print("❌ Could not find version in version.py")
sys.exit(1)
local_version = version_match.group(1)
print(f"📦 Local version: {local_version}")
# Get version from PyPI
package_name = "singlestore-mcp-server"
try:
pypi_response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
if pypi_response.status_code == 200:
pypi_data = pypi_response.json()
pypi_version = pypi_data["info"]["version"]
print(f"📦 PyPI version: {pypi_version}")
# Compare versions
if version.parse(local_version) <= version.parse(pypi_version):
print(f"❌ Error: Local version {local_version} is not greater than PyPI version {pypi_version}")
print("Please increment the version in src/version.py")
sys.exit(1)
else:
print(f"✅ Version check passed: {local_version} > {pypi_version}")
else:
if pypi_response.status_code == 404:
print(f"ℹ️ Package {package_name} not found on PyPI. This might be the first release.")
else:
print(f"⚠️ PyPI API returned status code {pypi_response.status_code}")
print(f"Response: {pypi_response.text}")
sys.exit(1)
except Exception as e:
print(f"❌ Error checking PyPI version: {e}")
sys.exit(1)
EOF