Skip to content

Commit d84f8d0

Browse files
committed
poll
1 parent 5422e9c commit d84f8d0

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

template/.github/workflows/publish.yaml.jinja

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,27 @@ jobs:
184184
python-version: ${{ matrix.python-version }}
185185
{% endraw %}{% if python_package_registry == "PyPI" %}{% raw %}
186186
- name: Sleep to allow PyPI Index to update before proceeding to the next step
187+
if: ${{ runner.os == 'Windows' }}
187188
uses: juliangruber/sleep-action@{% endraw %}{{ gha_sleep }}{% raw %}
188189
with:
189-
time: 60s{% endraw %}{% endif %}{% raw %}
190+
time: 60s
191+
- name: Wait for Test PyPI to serve the new version
192+
if: ${{ runner.os != 'Windows' }}
193+
run: |
194+
set -euo pipefail
195+
PKG="{% endraw %}{{ package_name | replace('_', '-') }}{% raw %}"
196+
VER="${{ needs.get-values.outputs.package-version }}"
197+
for i in $(seq 1 60); do
198+
code="$(curl -fsS -o /dev/null -w '%{http_code}' "https://test.pypi.org/pypi/${PKG}/${VER}/json" || true)"
199+
if [ "$code" = "200" ]; then
200+
echo "Found ${PKG}==${VER} on Test PyPI."
201+
exit 0
202+
fi
203+
echo "Not yet available; sleeping 5s..."
204+
sleep 5
205+
done
206+
echo "Timeout waiting for ${PKG}==${VER} on Test PyPI."
207+
exit 1{% endraw %}{% endif %}{% raw %}
190208
- name: Install from staging registry
191209
run: pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://www.pypi.org/simple {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package-version }} --no-cache
192210
- name: Display dependencies
@@ -297,9 +315,27 @@ jobs:
297315
python-version: ${{ matrix.python-version }}
298316
{% endraw %}{% if python_package_registry == "PyPI" %}{% raw %}
299317
- name: Sleep to allow PyPI Index to update before proceeding to the next step
318+
if: ${{ runner.os == 'Windows' }}
300319
uses: juliangruber/sleep-action@{% endraw %}{{ gha_sleep }}{% raw %}
301320
with:
302-
time: 60s{% endraw %}{% endif %}{% raw %}
321+
time: 60s
322+
- name: Wait for PyPI to serve the new version
323+
if: ${{ runner.os != 'Windows' }}
324+
run: |
325+
set -euo pipefail
326+
PKG="{% endraw %}{{ package_name | replace('_', '-') }}{% raw %}"
327+
VER="${{ needs.get-values.outputs.package-version }}"
328+
for i in $(seq 1 60); do
329+
code="$(curl -fsS -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/${PKG}/${VER}/json" || true)"
330+
if [ "$code" = "200" ]; then
331+
echo "Found ${PKG}==${VER} on PyPI."
332+
exit 0
333+
fi
334+
echo "Not yet available; sleeping 5s..."
335+
sleep 5
336+
done
337+
echo "Timeout waiting for ${PKG}==${VER} on PyPI."
338+
exit 1{% endraw %}{% endif %}{% raw %}
303339
- name: Install from primary registry
304340
run: pip install {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package-version }} --no-cache
305341
- name: Display dependencies

0 commit comments

Comments
 (0)