Skip to content

Commit 5f4590e

Browse files
RonnyPfannschmidtCursor AIclaude
committed
fix: validate release branch version is semver before using it
The `release-` prefix match was too broad — branches like `release-proposer` would set PRETEND_VERSION to `proposer`, breaking the build. Now validate that the suffix matches `^[0-9]+\.[0-9]+\.[0-9]+` before treating it as a version. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude Opus 4 <claude@anthropic.com>
1 parent 6d4845e commit 5f4590e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
if: startsWith(github.head_ref || '', 'release-')
2929
run: |
3030
VERSION="${GITHUB_HEAD_REF#release-}"
31-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
31+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
32+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
33+
fi
3234
3335
- uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0
3436
env:
@@ -171,19 +173,26 @@ jobs:
171173
id: version
172174
run: |
173175
VERSION="${GITHUB_HEAD_REF#release-}"
176+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
177+
echo "::notice::Branch $GITHUB_HEAD_REF is not a release version branch — skipping."
178+
exit 0
179+
fi
174180
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
175181
176182
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
183+
if: steps.version.outputs.version
177184
with:
178185
persist-credentials: false
179186

180187
- name: Download built packages
188+
if: steps.version.outputs.version
181189
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
182190
with:
183191
name: Packages
184192
path: dist
185193

186194
- name: Create or update draft release
195+
if: steps.version.outputs.version
187196
env:
188197
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189198
run: |

0 commit comments

Comments
 (0)