File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -26,20 +26,38 @@ jobs:
2626 steps :
2727 - name : Check out committed code
2828 uses : actions/checkout@v4
29- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
30- id : python
31- uses : actions/setup-python@v5
32- with :
33- python-version : ${{ env.DEFAULT_PYTHON }}
3429 - name : Prepare uv
3530 run : |
3631 pip install uv
3732 uv venv --seed venv
33+ . venv/bin/activate
34+ uv pip install toml
35+ - name : Check for existing package on PyPI
36+ id : check_package
37+ run : |
38+ . venv/bin/activate
39+ PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
40+ PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")
41+
42+ # Use jq to check for the version in the releases object
43+ EXISTING_VERSIONS=$(curl -s "https://pypi.org/pypi/$PACKAGE_NAME/json" | jq '.releases | keys[]')
44+
45+ echo "Checking for package: $PACKAGE_NAME==$PACKAGE_VERSION"
46+
47+ if [[ "$EXISTING_VERSIONS" =~ "$PACKAGE_VERSION" ]]; then
48+ echo "Package version already exists. Skipping upload."
49+ echo "should_publish=false" >> $GITHUB_OUTPUT
50+ else
51+ echo "Package version does not exist. Proceeding with upload."
52+ echo "should_publish=true" >> $GITHUB_OUTPUT
53+ fi
3854 - name : Build
55+ if : steps.check_package.outputs.should_publish == 'true'
3956 run : |
4057 . venv/bin/activate
4158 uv build
4259 - name : Publish distribution 📦 to PyPI
60+ if : steps.check_package.outputs.should_publish == 'true'
4361 run : |
4462 . venv/bin/activate
4563 uv publish
You can’t perform that action at this time.
0 commit comments