@@ -47,22 +47,29 @@ jobs:
4747 python -m build .
4848 echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
4949 echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
50- echo "DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)" >> $GITHUB_OUTPUT
51- # - name: Publish package
52- # run: |
53- # export HOST_UID=$(id -u)
54- # if [ "$TESTPYPI" == "true" ]; then
55- # export TWINE_REPOSITORY="testpypi"
56- # export TWINE_USERNAME=${TWINE_TEST_USERNAME}
57- # export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
58- # else
59- # export TWINE_REPOSITORY="pypi"
60- # fi
61- # docker compose run --build --quiet-pull \
62- # -e TWINE_USERNAME=${TWINE_USERNAME} \
63- # -e TWINE_PASSWORD=${TWINE_PASSWORD} \
64- # -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
65- # app sh -c "pip install twine && python -m twine upload dist/*"
50+ echo "NEW_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)" >> $GITHUB_ENV
51+ - name : Publish package
52+ run : |
53+ export HOST_UID=$(id -u)
54+ if [ "$TESTPYPI" == "true" ]; then
55+ LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
56+ export TWINE_REPOSITORY="testpypi"
57+ export TWINE_USERNAME=${TWINE_TEST_USERNAME}
58+ export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
59+ else
60+ LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
61+ export TWINE_REPOSITORY="pypi"
62+ fi
63+ # Check if the new version is different from the latest on PyPI, avoid re-uploading error
64+ if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
65+ docker compose run --build --quiet-pull \
66+ -e TWINE_USERNAME=${TWINE_USERNAME} \
67+ -e TWINE_PASSWORD=${TWINE_PASSWORD} \
68+ -e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
69+ app sh -c "pip install twine && python -m twine upload dist/*"
70+ else
71+ echo "::warning::The latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
72+ fi
6673 # Drafts your next Release notes as Pull Requests are merged into "master"
6774 - name : Draft release notes
6875 id : create_gh_release
0 commit comments