Skip to content

Commit 548a8d9

Browse files
shivasuryaclaude
andauthored
fix(ci): restrict PyPI publish to release events and manual triggers (#477)
Changes the PyPI publishing workflow to run only on: 1. Release published events (not drafts) - using 'release: types: [published]' 2. Manual workflow_dispatch with version input Removes the 'push: tags:' trigger that ran on any tag push. This provides better control over when PyPI packages are published: - Releases can be prepared as drafts without triggering publish - Only finalized releases trigger automatic publishing - Manual override available via workflow_dispatch when needed Updated version detection logic: - Extracts version from github.event.release.tag_name for releases - Strips 'v' prefix if present - Falls back to workflow_dispatch version input - Errors if neither source is available Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 18540ff commit 548a8d9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: Publish to PyPI
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
release:
5+
types: [published]
76
workflow_dispatch:
87
inputs:
98
version:
@@ -57,19 +56,20 @@ jobs:
5756
with:
5857
python-version: '3.11'
5958

60-
- name: Get version from tag
59+
- name: Get version from release or input
6160
id: version
6261
shell: bash
6362
run: |
6463
if [[ "${{ github.event.inputs.version }}" != "" ]]; then
6564
# Manual workflow_dispatch with version input
6665
VERSION="${{ github.event.inputs.version }}"
67-
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
68-
# Tag push
69-
VERSION=${GITHUB_REF#refs/tags/v}
66+
elif [[ "${{ github.event.release.tag_name }}" != "" ]]; then
67+
# Release published event - strip 'v' prefix if present
68+
VERSION="${{ github.event.release.tag_name }}"
69+
VERSION=${VERSION#v}
7070
else
71-
# Fallback for pull_request
72-
VERSION=$(python -c "import sys; sys.path.insert(0, 'python-sdk'); from codepathfinder import __version__; print(__version__)")
71+
echo "Error: No version source found. This workflow should be triggered by release publish or manual dispatch."
72+
exit 1
7373
fi
7474
echo "version=$VERSION" >> $GITHUB_OUTPUT
7575
echo "Version: $VERSION"

0 commit comments

Comments
 (0)