Skip to content

Commit

Permalink
Improve waiting for package to appear in PyPI index. Remove username …
Browse files Browse the repository at this point in the history
…and token when publishing to PyPI.
  • Loading branch information
jenskeiner committed Aug 17, 2023
1 parent 04c68ad commit 83df0d9
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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__)'
Expand All @@ -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__)'

0 comments on commit 83df0d9

Please sign in to comment.