Skip to content

Commit 5968fba

Browse files
fix: query PyPI version before building in API check
The previous approach failed because it would show the dev version after building current code. Now we query PyPI API directly before building to get the actual latest stable release for comparison.
1 parent 417d7c4 commit 5968fba

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

.github/workflows/api-check.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,18 @@ jobs:
3131
- name: Install the latest version of uv
3232
uses: astral-sh/setup-uv@v6
3333

34+
- name: Get latest PyPI version
35+
id: pypi-version
36+
run: |
37+
# Query PyPI for the latest stable version before building current code
38+
LATEST_VERSION=$(curl -s https://pypi.org/pypi/setuptools-scm/json | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
39+
echo "Latest PyPI version: $LATEST_VERSION"
40+
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
41+
3442
- name: Install dependencies
3543
run: uv sync --group test
3644

3745
- name: Check API stability against PyPI
3846
run: |
39-
# Get the latest version from PyPI
40-
LATEST_VERSION=$(uv pip show setuptools-scm 2>/dev/null | grep "^Version:" | cut -d' ' -f2 || echo "")
41-
if [ -z "$LATEST_VERSION" ]; then
42-
echo "No PyPI version found, installing latest release..."
43-
uv pip install setuptools-scm
44-
LATEST_VERSION=$(uv pip show setuptools-scm | grep "^Version:" | cut -d' ' -f2)
45-
fi
46-
echo "Comparing against PyPI version: $LATEST_VERSION"
47-
48-
# Compare current code against PyPI version
49-
uv run griffe check setuptools_scm -ssrc --verbose --against "setuptools-scm==$LATEST_VERSION"
47+
echo "Comparing current code against PyPI version: ${{ steps.pypi-version.outputs.version }}"
48+
uv run griffe check setuptools_scm -ssrc --verbose --against "setuptools-scm==${{ steps.pypi-version.outputs.version }}"

0 commit comments

Comments
 (0)