Skip to content

Commit b2ead4f

Browse files
authored
Merge pull request #3 from CoMPaTech/pypi
Improve publishing
2 parents 0af2108 + fb3448d commit b2ead4f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/workflows/verify.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,34 @@ jobs:
3737
run: |
3838
pip install uv
3939
uv venv --seed venv
40+
. venv/bin/activate
41+
uv pip install toml
42+
- name: Check for existing package on TestPyPI
43+
id: check_package
44+
run: |
45+
. venv/bin/activate
46+
PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
47+
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])")
48+
49+
# Use jq to check for the version in the releases object
50+
EXISTING_VERSIONS=$(curl -s "https://test.pypi.org/pypi/$PACKAGE_NAME/json" | jq '.releases | keys[]')
51+
52+
echo "Checking for package: $PACKAGE_NAME==$PACKAGE_VERSION"
53+
54+
if [[ "$EXISTING_VERSIONS" =~ "$PACKAGE_VERSION" ]]; then
55+
echo "Package version already exists. Skipping upload."
56+
echo "should_publish=false" >> $GITHUB_OUTPUT
57+
else
58+
echo "Package version does not exist. Proceeding with upload."
59+
echo "should_publish=true" >> $GITHUB_OUTPUT
60+
fi
4061
- name: Build
62+
if: steps.check_package.outputs.should_publish == 'true'
4163
run: |
4264
. venv/bin/activate
4365
uv build
4466
- name: Publish distribution 📦 to TestPyPI
67+
if: steps.check_package.outputs.should_publish == 'true'
4568
run: |
4669
. venv/bin/activate
4770
uv publish --publish-url https://test.pypi.org/legacy/

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 = "airos"
7-
version = "0.0.3a1"
7+
version = "0.0.3a2"
88
license = "MIT"
99
description = "Ubiquity airOS module(s) for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)