diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b0ec03..e4a2d3b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -50,8 +50,17 @@ jobs: - name: Install from testpypi and import. run: | i=0 - while (($i<120)) && [[ ! $(curl --max-time 120 -s https://test.pypi.org/pypi/${{ env.PACKAGE_NAME }}/json | jq -r '.releases | keys[]') =~ (^|[[:space:]])${{ env.VERSION }}($|[[:space:]]) ]];\ - do echo waiting for package to appear in test index, sleeping 5s; sleep 5s; let i++; done + n=60 + exists=0 + while [ $i -lt $n ] && [ $exists -eq 0 ]; do + if curl -s https://test.pypi.org/pypi/${{ env.PACKAGE_NAME }}/json | jq -e '.releases | has("${{ env.VERSION }}")' &> /dev/null; then + exists=1 + else + ((i++)) + echo "$i/$n Waiting for package to appear in test index, sleeping 5s." + sleep 5s + fi + done pip install --no-cache-dir --index-url https://test.pypi.org/simple ${{ env.PACKAGE_NAME }}==${{ env.VERSION }} --no-deps pip install -r requirements.txt python -c 'import ${{ env.MODULE_NAME }};print(${{ env.MODULE_NAME }}.__version__)' @@ -61,13 +70,19 @@ jobs: pip cache purge - name: Publish package to PyPI. uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} - name: Install and import. run: | i=0 - while (($i<120)) && [[ ! $(curl --max-time 120 -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json | jq -r '.releases | keys[]') =~ (^|[[:space:]])${{ env.VERSION }}($|[[:space:]]) ]];\ - do echo waiting for package to appear in index, sleeping 5s; sleep 5s; let i++; done + n=60 + exists=0 + while [ $i -lt $n ] && [ $exists -eq 0 ]; do + if curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json | jq -e '.releases | has("${{ env.VERSION }}")' &> /dev/null; then + exists=1 + else + ((i++)) + echo "$i/$n Waiting for package to appear in test index, sleeping 5s." + sleep 5s + fi + done pip install --no-cache-dir --index-url https://pypi.org/simple ${{ env.PACKAGE_NAME }}==${{ env.VERSION }} python -c 'import ${{ env.MODULE_NAME }};print(${{ env.MODULE_NAME }}.__version__)'