1

What I am trying to do:

I am trying to set up a deployment environment tag rule in Github with the recommended Semver regex pattern on the bottom of page here: https://semver.org/

Issue I am encountering:

The Semver pattern I use is 180 characters long. Github rule allows only 100 characters, so it truncates the tail of the pattern.

I reduced the length to 87, with no luck. Eventually, I left only the core major.minor.patch portion, which still didn't work for another reason.

Original ^(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-]+)*))?$

Attempt 2 ^(0|[1-9]\d*).(0|[1-9]\d*).(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))

Attempt 3 ^(0|[1-9]\d*).(0|[1-9]\d*).(0|[1-9]\d*)

Is there any way to set the pattern another way or is shortening it the only solution?

2
  • No idea what the issue is, but doesn't attempt 3 prove your issue isn't one of char length? Commented Nov 27, 2023 at 18:00
  • I would say the opposite: Github has a length limitation that prevents the use of patterns longer than 100 characters and also doesn't seem to work well with the SemVer patterns for other reasons. regex101.com/r/5lUsPh/1 I found an answer here: docs.github.com/en/repositories/… GitHub actually uses fnmatch for pattern matching, not a regular Regex. Commented Nov 28, 2023 at 19:31

1 Answer 1

1

Github uses fnmatch for the Tag Rules, not regular Regex pattern.

More here: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/configuring-tag-protection-rules#adding-tag-protection-rules

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.