Skip to content

Commit d0e6adc

Browse files
authored
Refine version extraction and add OIDC cleanup step
Updated version extraction regex for wheel and source distribution files. Added cleanup step for attestations after OIDC failure.
1 parent 8a8f8e0 commit d0e6adc

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,23 @@ jobs:
103103
echo "Tag SHA: $TAG_SHA"
104104
105105
# ── Find or trigger run by SHA on ffi branch ─────────────
106+
EXPECTED_VER="${TAG#v}"
107+
echo "Expected version: $EXPECTED_VER"
108+
106109
find_run() {
107110
local WF=$1
111+
echo " Scanning $WF for run matching version $EXPECTED_VER..." >&2
108112
gh api "repos/${{ github.repository }}/actions/workflows/$WF/runs?branch=$BRANCH&per_page=20" \
109113
--jq ".workflow_runs[] | select(.conclusion == \"success\") | .id" \
110-
2>/dev/null | head -1
114+
2>/dev/null | while read -r RUN_ID; do
115+
ARTIFACT_NAMES=$(gh api "repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts?per_page=10" \
116+
--jq '[.artifacts[].name] | join(",")' 2>/dev/null || true)
117+
echo " run $RUN_ID artifacts: $ARTIFACT_NAMES" >&2
118+
if echo "$ARTIFACT_NAMES" | grep -qF "$EXPECTED_VER"; then
119+
echo "$RUN_ID"
120+
return
121+
fi
122+
done | head -1
111123
}
112124
113125
trigger_if_missing() {
@@ -263,11 +275,11 @@ jobs:
263275
ls -la dist/ 2>/dev/null || echo "dist/ empty or missing"
264276
echo "DEBUG: whl count: $(find dist/ -name "*.whl" 2>/dev/null | wc -l)"
265277
echo "DEBUG: sdist count: $(find dist/ -name "*.tar.gz" 2>/dev/null | wc -l)"
266-
echo "DEBUG: VERSION=$(find dist/ -name "*.whl" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[^-]+')"
278+
echo "DEBUG: VERSION=$(find dist/ -name "*.whl" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[0-9][^-]+')"
267279
echo "DEBUG: next steps will check these counts"
268-
VERSION=$(find dist/ -name "*.whl" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[^-]+' || true)
280+
VERSION=$(find dist/ -name "*.whl" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[0-9][^-]+' || true)
269281
if [ -z "$VERSION" ]; then
270-
VERSION=$(find dist/ -name "*.tar.gz" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[^-]+')
282+
VERSION=$(find dist/ -name "*.tar.gz" 2>/dev/null | head -1 | grep -oP '(?<=uv_ffi-)[0-9][^-]+(?:\.[a-z]+[0-9]+)?' || true)
271283
fi
272284
if [ -z "$VERSION" ]; then
273285
echo "No wheels or sdist left in dist/, nothing to do"
@@ -304,6 +316,14 @@ jobs:
304316
packages-dir: dist/
305317
skip-existing: true
306318

319+
- name: Clean attestations after OIDC failure
320+
if: steps.oidc.outcome == 'failure'
321+
run: |
322+
echo "OIDC failed — purging any generated attestations before fallback..."
323+
find dist/ -name "*.attestation" -delete 2>/dev/null || true
324+
echo "dist/ contents:"
325+
ls -lh dist/
326+
307327
- name: Publish via API token (fallback)
308328
if: steps.oidc.outcome == 'failure'
309329
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)