Skip to content

Commit 8ee67fb

Browse files
committed
Allowed ContinuousDelivery versioning to comply with GitVersion policy
To fix issues with publishing "pre-release" branches (dev/"-alpha"). Signed-off-by: Nikita Neverov <neverovnikita.bmt@gmail.com>
1 parent 5edc09a commit 8ee67fb

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@ description: >-
1212
inputs:
1313
version:
1414
description: >-
15-
Version from the tag (e.g. v1.0.0 or v1.0.0-alpha)
15+
Version from the tag (e.g. v1.0.0, v1.0.0-alpha, v1.0.0-alpha.1)
1616
required: true
1717
version-regex:
18-
description: >-
19-
Regular expression to check the version format and filter existing tags
18+
description: |-
19+
Regular expression to check the version format and filter existing tags.
20+
Default supports SemVer core "vMAJOR.MINOR.PATCH" with optional dotted prerelease:
21+
"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")
2025
required: false
21-
# Format: vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-PRERELEASE
26+
# Format: vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-PRERELEASE(.MORE)*
27+
# Group #1 = full prerelease ("alpha.1"), Group #2 = first identifier ("alpha")
2228
default: >-
23-
^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z]+))?$
29+
^v[0-9]+\.[0-9]+\.[0-9]+(?:-(([0-9A-Za-z]+)(?:\.[0-9A-Za-z-]+)*))?$
2430
allowed-prerelease-suffix-regex:
2531
description: >-
26-
Regular expression for acceptable prerelease values (e.g. "^(alpha|beta|rc)$")
32+
Regular expression for acceptable prerelease values (e.g. "^(alpha|beta|rc)$").
33+
This is matched against the FIRST prerelease identifier (capturing group #2)
2734
required: true
2835

2936
outputs:
@@ -67,11 +74,13 @@ runs:
6774
#######################################
6875
# Validates the version string against a regex and evaluates prerelease rules.
6976
#
70-
# Notes:
71-
# - With the default regex, capturing group #2 is the prerelease token (no leading dash).
77+
# 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"),
80+
# which is used to validate against allowed_prerelease_suffix_regex.
7281
#
7382
# Arguments (read-only):
74-
# 1: version - Tag version to validate (e.g., v1.2.3, v1.2.3-rc).
83+
# 1: version - Tag version to validate (e.g., v1.2.3, v1.2.3-rc.1).
7584
# 2: version_regex - Regex to validate format (and to provide capturing groups).
7685
# 3: allowed_prerelease_suffix_regex - Regex for allowed prerelease labels (e.g., ^(alpha|beta|rc)$).
7786
# Outputs (by reference, via nameref):
@@ -93,13 +102,13 @@ runs:
93102
94103
echo '::group::Validate format & prerelease'
95104
if [[ "$version" =~ $version_regex ]]; then
96-
# If the regex defines a prerelease capturing group (default: group #2), use it:
105+
# If the regex defines a prerelease capturing group (#2 = first identifier), use it:
97106
if [[ -z "${BASH_REMATCH[2]:-}" ]]; then
98107
echo "::notice title=Format OK::'$version' matches regex and has no prerelease"
99108
_is_publishable=true
100109
else
101110
_is_prerelease=true
102-
local -r prerelease_token="${BASH_REMATCH[2]}"
111+
local -r prerelease_token="${BASH_REMATCH[2]}" # e.g., "alpha"
103112
echo "::notice title=Prerelease detected::'${prerelease_token}'"
104113
105114
if [[ "$prerelease_token" =~ $allowed_prerelease_suffix_regex ]]; then
@@ -289,11 +298,11 @@ runs:
289298
for tag in "${tags[@]}"; do
290299
printf ' - %s\n' "$tag"
291300
done
292-
301+
293302
highest=''
294303
select_max_version tags highest
295304
echo "Highest existing version: '${highest}'"
296-
305+
297306
echo '::group::Compare new vs highest existing'
298307
cmp=0
299308
compare_versions_semver_like "$version" "$highest" cmp

0 commit comments

Comments
 (0)