Skip to content

Commit

Permalink
add tag validation to Pypi publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristoGrab committed Nov 19, 2024
1 parent 2f3f211 commit 90b29fc
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,44 @@ jobs:
name: Packages
path: dist

- name: Debug Reference
run: |
echo "Event Name: $GITHUB_EVENT_NAME"
echo "GitHub Ref: $GITHUB_REF"
- name: Validate Tag Reference
run: |
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
echo "Workflow triggered via dispatch."
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v ]]; then
echo "Error: This workflow requires a valid tag (refs/tags/vX.Y.Z) to run."
exit 1
fi
else
echo "Workflow triggered by tag push."
fi
- name: Extract and Validate Version
id: extract_version
run: |
if [[ "$GITHUB_REF" =~ ^refs/tags/v(.+)$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
else
echo "Error: GITHUB_REF does not point to a valid tag. Found: $GITHUB_REF"
exit 1
fi
- name: Attach Wheel to GitHub Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.whl
tag: ${{ github.ref }}
tag: ${{ github.ref#refs/tags/ }}
overwrite: true
file_glob: true

- name: Debug PyPI Publish Step
run: |
echo "This is where PyPI publishing would occur."
echo "Package files in 'dist/':"
ls -lh dist/
- name: Publish to PyPI (${{vars.PYPI_PUBLISH_URL}})
uses: pypa/[email protected]
with:
Expand Down

0 comments on commit 90b29fc

Please sign in to comment.