Skip to content

Commit 48e142b

Browse files
Handle published prereleases in release workflow
1 parent 30359a8 commit 48e142b

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,29 @@ jobs:
6868
6969
- name: Check if version is on PyPI
7070
id: pypi_check
71+
env:
72+
VERSION: ${{ steps.version.outputs.version }}
7173
run: |
72-
if pip index versions pycyphal2 2>/dev/null | grep -qF "${{ steps.version.outputs.version }}"; then
74+
if python - <<'PY'
75+
from __future__ import annotations
76+
77+
import json
78+
import os
79+
import urllib.error
80+
import urllib.request
81+
82+
version = os.environ["VERSION"]
83+
try:
84+
with urllib.request.urlopen("https://pypi.org/pypi/pycyphal2/json", timeout=20) as response:
85+
data = json.load(response)
86+
except urllib.error.HTTPError as ex:
87+
if ex.code == 404:
88+
raise SystemExit(1)
89+
raise
90+
91+
raise SystemExit(0 if version in data.get("releases", {}) else 1)
92+
PY
93+
then
7394
echo "exists=true" >> "$GITHUB_OUTPUT"
7495
else
7596
echo "exists=false" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)