Skip to content

Commit 6afe9cb

Browse files
Fix publish-pypi to trigger after build-wheels completes
Previously triggered on release:published which raced with build-wheels. Now uses workflow_run to chain: tag push → build-wheels → publish-pypi.
1 parent f4ffd4f commit 6afe9cb

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
name: Publish to PyPI
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_run:
5+
workflows: ["Build wheels"]
6+
types: [completed]
67
workflow_dispatch:
78
inputs:
89
tag:
9-
description: "Release tag to publish (e.g. v0.0.20)"
10+
description: "Release tag to publish (e.g. v0.5.26)"
1011
required: true
1112

1213
jobs:
1314
publish:
1415
name: Upload to PyPI
1516
runs-on: ubuntu-latest
17+
# Only run if build-wheels succeeded (or manual dispatch)
18+
if: >-
19+
github.event_name == 'workflow_dispatch' ||
20+
(github.event.workflow_run.conclusion == 'success' &&
21+
startsWith(github.event.workflow_run.head_branch, 'v'))
1622
permissions:
1723
contents: read
1824
id-token: write
1925
steps:
26+
- name: Determine tag
27+
id: tag
28+
run: |
29+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
30+
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
31+
else
32+
echo "tag=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT"
33+
fi
34+
2035
- name: Download release assets
2136
env:
2237
GH_TOKEN: ${{ github.token }}
2338
run: |
24-
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
39+
TAG="${{ steps.tag.outputs.tag }}"
40+
echo "Downloading wheels for ${TAG}..."
2541
mkdir -p dist
2642
gh release download "${TAG}" \
2743
--repo "${{ github.repository }}" \
2844
--dir dist \
2945
--pattern "*.whl"
46+
ls -la dist/
3047
3148
- uses: pypa/gh-action-pypi-publish@release/v1
3249
with:

0 commit comments

Comments
 (0)