diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index fe7f79d..f96def6 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -37,11 +37,34 @@ jobs: run: | pip install uv uv venv --seed venv + . venv/bin/activate + uv pip install toml + - name: Check for existing package on TestPyPI + id: check_package + run: | + . venv/bin/activate + PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") + PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])") + + # Use jq to check for the version in the releases object + EXISTING_VERSIONS=$(curl -s "https://test.pypi.org/pypi/$PACKAGE_NAME/json" | jq '.releases | keys[]') + + echo "Checking for package: $PACKAGE_NAME==$PACKAGE_VERSION" + + if [[ "$EXISTING_VERSIONS" =~ "$PACKAGE_VERSION" ]]; then + echo "Package version already exists. Skipping upload." + echo "should_publish=false" >> $GITHUB_OUTPUT + else + echo "Package version does not exist. Proceeding with upload." + echo "should_publish=true" >> $GITHUB_OUTPUT + fi - name: Build + if: steps.check_package.outputs.should_publish == 'true' run: | . venv/bin/activate uv build - name: Publish distribution 📦 to TestPyPI + if: steps.check_package.outputs.should_publish == 'true' run: | . venv/bin/activate uv publish --publish-url https://test.pypi.org/legacy/ diff --git a/pyproject.toml b/pyproject.toml index 8ad1930..57980ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "airos" -version = "0.0.3a1" +version = "0.0.3a2" license = "MIT" description = "Ubiquity airOS module(s) for Python 3." readme = "README.md"