Skip to content

Commit 83f4825

Browse files
snus-kinCopilot
andauthored
Update .github/workflows/ci.yml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c9a4b8a commit 83f4825

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,40 @@ jobs:
206206
name: dist
207207
path: dist/
208208

209+
- name: Verify package version matches release tag
210+
run: |
211+
# Extract version from release tag (remove leading 'v' if present)
212+
TAG_VERSION="${GITHUB_REF#refs/tags/}"
213+
TAG_VERSION="${TAG_VERSION#v}"
214+
echo "Release tag version: $TAG_VERSION"
215+
# Find the first wheel or sdist in dist/
216+
FILE=$(ls dist/*.whl 2>/dev/null || ls dist/*.tar.gz 2>/dev/null)
217+
if [[ -z "$FILE" ]]; then
218+
echo "No distribution file found in dist/"
219+
exit 1
220+
fi
221+
echo "Checking version in: $FILE"
222+
if [[ "$FILE" == *.whl ]]; then
223+
# Extract version from wheel filename: name-version-*.whl
224+
FILENAME=$(basename "$FILE")
225+
# Remove extension
226+
FILENAME="${FILENAME%.whl}"
227+
# Extract version (assumes format: name-version-...)
228+
PKG_VERSION=$(echo "$FILENAME" | awk -F'-' '{print $(NF-2)}')
229+
elif [[ "$FILE" == *.tar.gz ]]; then
230+
# Extract version from sdist filename: name-version.tar.gz
231+
FILENAME=$(basename "$FILE")
232+
FILENAME="${FILENAME%.tar.gz}"
233+
PKG_VERSION=$(echo "$FILENAME" | awk -F'-' '{print $NF}')
234+
else
235+
echo "Unknown distribution file type: $FILE"
236+
exit 1
237+
fi
238+
echo "Package version: $PKG_VERSION"
239+
if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then
240+
echo "Version mismatch: tag version is $TAG_VERSION, package version is $PKG_VERSION"
241+
exit 1
242+
fi
243+
echo "Version check passed."
209244
- name: Publish package distributions to PyPI
210245
run: uv publish --trusted-publishing always

0 commit comments

Comments
 (0)