diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index a1d62a84e..ae2a7de26 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -19,6 +19,11 @@ jobs: uses: actions/checkout@v4 - name: Create release run: | + VERSION=$(./scripts/version-core) + if pip index versions pyglossary --pre | grep "$VERSION," ; then + echo 'Package version $VERSION already exists on pypi' + exit 0 + fi sudo rm -rf dist/* build/* || true python3 setup.py sdist bdist_wheel - name: Publish package distributions to PyPI diff --git a/scripts/version-core b/scripts/version-core new file mode 100755 index 000000000..f78d77e36 --- /dev/null +++ b/scripts/version-core @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +sourceDir=$(dirname $(dirname "$0")) + +while read -r line; do + if [[ $line = VERSION* ]]; then + echo "$line" | sed 's/VERSION\s*=\s*//' | sed 's/"//g' + exit 0 + fi +done <"$sourceDir/pyglossary/core.py"