Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Publish to PyPI

on:
push:
tags:
- 'v*'
release:
types: [published]
workflow_dispatch:
inputs:
version:
Expand Down Expand Up @@ -57,19 +56,20 @@ jobs:
with:
python-version: '3.11'

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