Skip to content

Commit 422f2b2

Browse files
chore: add PEP 440 version format validation
Reject bump keywords (patch, major, etc.) and malformed inputs with a clear error before any file is modified, matching the pattern added to the splunk-ao and splunk-ao-adk release workflows Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d51d65a commit 422f2b2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/release-splunk-ao-a2a-test.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66
inputs:
77
version:
8-
description: 'Version to publish (e.g., 0.1.0, 1.2.3b1). Leave empty to use the version in pyproject.toml as-is.'
8+
description: 'Version to publish (e.g., 0.1.0, 1.2.3b1). Must be an explicit PEP 440 version. Leave empty to use the version in pyproject.toml as-is.'
99
required: false
1010
type: string
1111

@@ -67,12 +67,16 @@ jobs:
6767
sed -i "s/^version = \".*\"/version = \"${PRE_VERSION}\"/" pyproject.toml
6868
sed -i "s/__version__ = \".*\"/__version__ = \"${PRE_VERSION}\"/" src/splunk_ao_a2a/_version.py
6969
70-
# Manual dispatch: use the supplied version if provided.
70+
# Manual dispatch: validate and use the supplied version if provided.
7171
- name: Override version
7272
if: github.event_name == 'workflow_dispatch' && inputs.version != ''
7373
env:
7474
INPUT_VERSION: ${{ inputs.version }}
7575
run: |
76+
if ! printf '%s' "$INPUT_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([abprc.][0-9]+)*$'; then
77+
echo "::error::Invalid version '${INPUT_VERSION}'. Expected an explicit PEP 440 version (e.g. 0.1.0, 1.2.3b1). Bump keywords like 'patch' or 'major' are not accepted."
78+
exit 1
79+
fi
7680
sed -i "s/^version = \".*\"/version = \"${INPUT_VERSION}\"/" pyproject.toml
7781
sed -i "s/__version__ = \".*\"/__version__ = \"${INPUT_VERSION}\"/" src/splunk_ao_a2a/_version.py
7882

0 commit comments

Comments
 (0)