diff --git a/.drone.yml b/.drone.yml index 5c5c74b..a8211f6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -38,14 +38,19 @@ platform: arch: amd64 steps: + - name: Newer version to publish? + image: python:3.10 + commands: + - bash publish_version?.sh + - name: Test PyPi publish image: python:3.10 commands: - - make dist - - pip3 install -r requirements.txt - - pip3 install twine - - twine check dist/* - - twine upload --repository delugeClient-kevin dist/* + - make dist + - pip3 install -r requirements.txt + - pip3 install twine + - twine check dist/* + - twine upload --repository delugeClient-kevin dist/* - name: PyPi publish image: python:3.10 diff --git a/publish_version?.sh b/publish_version?.sh new file mode 100644 index 0000000..74e31c4 --- /dev/null +++ b/publish_version?.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +PYPI_VERSION=$(pip3 show delugeClient-kevin | awk '$1 ~ /Version:/ { print $2 }') +SOURCE_VERSION=$(python3 delugeClient/__version__.py) + +echo "hello" +echo "pypi version: $PYPI_VERSION" +echo "source version: $SOURCE_VERSION" + +function version { + echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; +} + +if [ $(version $SOURCE_VERSION) -gt $(version $PYPI_VERSION) ]; then + echo "source is newer than pypi" + exit 0 +else + exit 1 + echo "source is same or oldre, but not newer" +fi \ No newline at end of file