Skip to content

Commit 4747c66

Browse files
committed
Skip check for tool-merging as well
1 parent 1558dfe commit 4747c66

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

.github/workflows/merge.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)