Skip to content

Commit bdba989

Browse files
committed
validate release tag
1 parent 585b17e commit bdba989

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

.github/workflows/release_python.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,27 @@ jobs:
4242
steps:
4343
- run: echo 'The Publish workflow passed or was manually triggered'
4444

45-
sdist:
45+
validate-release-tag:
4646
runs-on: ubuntu-latest
4747
needs: [check-cargo-publish]
48+
steps:
49+
- name: Validate release tag format
50+
# Note, `workflow_run.head_branch` does not contain `refs/tags/` prefix, just the tag name, i.e. `v0.4.0` or `v0.4.0-rc.1`
51+
# Valid formats: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>
52+
run: |
53+
RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
54+
echo "Validating release tag: $RELEASE_TAG"
55+
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
56+
echo "❌ Invalid release tag format: $RELEASE_TAG"
57+
echo "Expected format: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc.<release_candidate>"
58+
echo "Examples: v0.4.0, v1.2.3-rc.1"
59+
exit 1
60+
fi
61+
echo "✅ Release tag format is valid: $RELEASE_TAG"
62+
63+
sdist:
64+
runs-on: ubuntu-latest
65+
needs: [validate-release-tag]
4866
steps:
4967
- uses: actions/checkout@v4
5068
- uses: PyO3/maturin-action@v1
@@ -60,7 +78,7 @@ jobs:
6078

6179
wheels:
6280
runs-on: "${{ matrix.os }}"
63-
needs: [check-cargo-publish]
81+
needs: [validate-release-tag]
6482
strategy:
6583
matrix:
6684
include:
@@ -108,17 +126,6 @@ jobs:
108126
id-token: write # IMPORTANT: mandatory for trusted publishing
109127

110128
steps:
111-
- name: Validate release tag format
112-
# Note, `workflow_run.head_branch` does not contain `refs/tags/` prefix, just the tag name, i.e. `v0.4.0` or `v0.4.0-rc.1`
113-
run: |
114-
RELEASE_TAG="${{ github.event.workflow_run.head_branch }}"
115-
echo "Validating release tag: $RELEASE_TAG"
116-
if [[ ! "$RELEASE_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? ]]; then
117-
echo "❌ Invalid release tag format: $RELEASE_TAG"
118-
exit 1
119-
fi
120-
echo "✅ Release tag format is valid"
121-
122129
- name: Download all the dists
123130
uses: actions/download-artifact@v4
124131
with:

0 commit comments

Comments
 (0)