Skip to content

Commit 179a4ee

Browse files
committed
Prevent action failure on merge for tooling
1 parent de4307e commit 179a4ee

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
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

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Changelog
22

3-
## Ongoing / 1.7.8a0
3+
## Ongoing / 1.7.8a0+1
44

5-
- Chores move module publishing on (test)pypi to Trusted Publishing (and using uv) - released as alpha 1.7.8a0 to demonstrate functionality
5+
- Chores move module publishing on (test)pypi to Trusted Publishing (and using uv) - released as alpha 1.7.8a0+1 to demonstrate functionality
66

77
## v1.7.7
88

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "1.7.8a0"
7+
version = "1.7.8a1"
88
license = "MIT"
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)