Skip to content

Commit

Permalink
fix: Fix regex expresion used in 'try-parse-tag' step to make it more…
Browse files Browse the repository at this point in the history
… POSIX compatible
  • Loading branch information
vicfergar committed Apr 1, 2022
1 parent aae62e8 commit 79a04b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tag-nuget-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- id: parse
run: |
# This pattern comes from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# However, Bash uses POSIX regular expressions, and POSIX does not support non-capturing groups: (?:...)
# To make it compatible, the non-capture modifiers have been removed.
semantic_version_pattern='^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-((0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
# However, Bash uses POSIX regular expressions, and POSIX does not support non-capturing groups (?:...) and uses different metacharacters (ex: \d)
# To make it compatible, the non-capture modifiers have been removed and the metacharacter for digits (\d) has been replaced by `[0-9]`
semantic_version_pattern='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
if [[ ${TAG_NAME} =~ $semantic_version_pattern ]]; then
echo ::set-output name=is_semantic_version::'true'
if [[ ${BASH_REMATCH[4]} != '' ]]; then
Expand Down

0 comments on commit 79a04b8

Please sign in to comment.