Skip to content

Commit b05cc70

Browse files
committed
fixing workflow
1 parent 83a84c8 commit b05cc70

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.github/workflows/pypi.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535

3636
publish-to-pypi:
3737
name: Publish to PyPI
38-
if: startsWith(github.ref, 'refs/tags/') && contains(github.ref_name, 'v') && github.ref_name matches '^v[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$'
3938
needs:
4039
- build
4140
runs-on: ubuntu-22.04
@@ -44,6 +43,24 @@ jobs:
4443
id-token: write # IMPORTANT: mandatory for trusted publishing
4544

4645
steps:
46+
- name: Extract tag name
47+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
48+
49+
- name: Validate tag format
50+
id: validate_tag
51+
run: |
52+
if [[ "${{ env.TAG_NAME }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$ ]]; then
53+
echo "valid=true" >> $GITHUB_ENV
54+
else
55+
echo "valid=false" >> $GITHUB_ENV
56+
fi
57+
58+
- name: Exit if invalid tag
59+
if: env.valid == 'false'
60+
run: |
61+
echo "The tag ${{ env.TAG_NAME }} is not a valid semantic version. Exiting."
62+
exit 1
63+
4764
- name: Download all the distribution packages
4865
uses: actions/download-artifact@v4
4966
with:

0 commit comments

Comments
 (0)