Skip to content

Commit 3160b4b

Browse files
committed
✨ 添加依赖版本检测
1 parent 775596b commit 3160b4b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,23 @@ jobs:
2020

2121
- uses: pdm-project/setup-pdm@v3
2222

23+
- name: Get current version from PyPI
24+
id: get_pypi_version
25+
run: |
26+
PACKAGE_NAME=$(pdm info | grep 'Name:' | awk '{print $2}')
27+
CURRENT_VERSION=$(pdm info | grep 'Version:' | awk '{print $2}')
28+
PYPI_VERSION=$(curl -s https://pypi.org/pypi/$PACKAGE_NAME/json | jq -r '.info.version')
29+
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
30+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
31+
echo "PYPI_VERSION=$PYPI_VERSION" >> $GITHUB_ENV
32+
33+
- name: Check if versions are different
34+
id: check_versions
35+
run: |
36+
if [ "$CURRENT_VERSION" != "$PYPI_VERSION" ]; then
37+
echo "versions_different=true" >> $GITHUB_ENV
38+
else
39+
echo "versions_different=false" >> $GITHUB_ENV
40+
2341
- name: Publish package distributions to PyPI
24-
run: pdm publish
42+
run: pdm publish

0 commit comments

Comments
 (0)