Skip to content

Commit a4bbfab

Browse files
committed
Fixed parsing of pre-release versions during tags validation
Signed-off-by: Nikita Neverov <neverovnikita.bmt@gmail.com>
1 parent 8ee67fb commit a4bbfab

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

.github/actions/check-tag-version/action.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ inputs:
1717
version-regex:
1818
description: |-
1919
Regular expression to check the version format and filter existing tags.
20-
Default supports SemVer core "vMAJOR.MINOR.PATCH" with optional dotted prerelease:
20+
POSIX ERE compatible. Supports SemVer core "vMAJOR.MINOR.PATCH" with optional dotted prerelease:
2121
"vMAJOR.MINOR.PATCH-PRERELEASE(.MORE)*".
22-
Capturing groups:
23-
- Group #1: full prerelease part without the leading dash (e.g. "alpha.1")
24-
- Group #2: first prerelease identifier (e.g. "alpha")
22+
Capturing groups (for the DEFAULT regex):
23+
- Group #2: full prerelease part without the leading dash (e.g. "alpha.1")
24+
- Group #3: first prerelease identifier (e.g. "alpha")
2525
required: false
2626
# Format: vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-PRERELEASE(.MORE)*
27-
# Group #1 = full prerelease ("alpha.1"), Group #2 = first identifier ("alpha")
27+
# Group #2 = full prerelease ("alpha.1"), Group #3 = first identifier ("alpha")
2828
default: >-
29-
^v[0-9]+\.[0-9]+\.[0-9]+(?:-(([0-9A-Za-z]+)(?:\.[0-9A-Za-z-]+)*))?$
29+
^v[0-9]+\.[0-9]+\.[0-9]+(-(([0-9A-Za-z]+)(\.[0-9A-Za-z-]+)*))?$
3030
allowed-prerelease-suffix-regex:
3131
description: >-
3232
Regular expression for acceptable prerelease values (e.g. "^(alpha|beta|rc)$").
33-
This is matched against the FIRST prerelease identifier (capturing group #2)
33+
This is matched against the FIRST prerelease identifier (capturing group #3)
3434
required: true
3535

3636
outputs:
@@ -75,8 +75,8 @@ runs:
7575
# Validates the version string against a regex and evaluates prerelease rules.
7676
#
7777
# Notes (for the DEFAULT regex):
78-
# - Capturing group #1 = full prerelease without the leading dash (e.g., "alpha.1").
79-
# - Capturing group #2 = first prerelease identifier (e.g., "alpha"),
78+
# - Capturing group #2 = full prerelease without the leading dash (e.g., "alpha.1").
79+
# - Capturing group #3 = first prerelease identifier (e.g., "alpha"),
8080
# which is used to validate against allowed_prerelease_suffix_regex.
8181
#
8282
# Arguments (read-only):
@@ -102,13 +102,13 @@ runs:
102102
103103
echo '::group::Validate format & prerelease'
104104
if [[ "$version" =~ $version_regex ]]; then
105-
# If the regex defines a prerelease capturing group (#2 = first identifier), use it:
105+
# Group #2 = full prerelease; Group #3 = first identifier:
106106
if [[ -z "${BASH_REMATCH[2]:-}" ]]; then
107107
echo "::notice title=Format OK::'$version' matches regex and has no prerelease"
108108
_is_publishable=true
109109
else
110110
_is_prerelease=true
111-
local -r prerelease_token="${BASH_REMATCH[2]}" # e.g., "alpha"
111+
local -r prerelease_token="${BASH_REMATCH[3]}" # e.g., "alpha"
112112
echo "::notice title=Prerelease detected::'${prerelease_token}'"
113113
114114
if [[ "$prerelease_token" =~ $allowed_prerelease_suffix_regex ]]; then
@@ -191,7 +191,7 @@ runs:
191191
# Loads tags that look like versions into an array, excluding the current one.
192192
#
193193
# Arguments (read-only):
194-
# 1: version_regex - Regex to filter version-like tags.
194+
# 1: version_regex - Regex to filter version-like tags (POSIX ERE).
195195
# 2: excluded_exact_tag - Tag to exclude from the list (exact match).
196196
# Outputs (by reference, via nameref):
197197
# 3: _tags (array) - Filled with matching tag names.
@@ -233,8 +233,7 @@ runs:
233233
local -n _cmp="$3"
234234
235235
if [[ "$version_a" == "$version_b" ]]; then
236-
_cmp=0
237-
return 0
236+
_cmp=0; return 0
238237
fi
239238
240239
# `sort -V` does version-aware ordering; head is the smaller, tail is the larger:

0 commit comments

Comments
 (0)