-
Notifications
You must be signed in to change notification settings - Fork 9
39 lines (33 loc) · 1.19 KB
/
Copy pathversion-check.yml
File metadata and controls
39 lines (33 loc) · 1.19 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
name: Version Check
on:
pull_request:
branches:
- main
paths:
- "pyproject.toml"
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Get Local Version
id: local_version
run: |
# Extracts version from pyproject.toml using uv
VERSION=$(grep -m 1 '^version = ' pyproject.toml | cut -d '"' -f 2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected local version: $VERSION"
- name: Check PyPI Version
id: pypi_check
run: |
PACKAGE_NAME=$(grep -m 1 "name =" pyproject.toml | cut -d '"' -f 2)
# Query PyPI API for the latest version
LATEST_PYPI=$(curl -s https://pypi.org/pypi/$PACKAGE_NAME/json | jq -r '.info.version' || echo "0.0.0")
if [ "${{ steps.local_version.outputs.version }}" == "$LATEST_PYPI" ]; then
echo "Version ${{ steps.local_version.outputs.version }} already exists on PyPI!"
exit 1
else
echo "Version bump detected: $LATEST_PYPI -> ${{ steps.local_version.outputs.version }}"
fi