mathieudutour / github-tag-action

A Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.
https://github.com/marketplace/actions/github-tag
MIT License
640 stars 201 forks source link

Default value for release_branches unexpectedly matches substring #219

Open remy-niles opened 3 months ago

remy-niles commented 3 months ago

I am willing to provide a simple pull request to fix the following issue, and am opening an issue to get some initial feedback.

The default values used for the release_branches parameter are matched as substrings by default instead of an exact string and so in some cases where the letters "main" or "master" appear in a branch name, a release tag will be generated. An example would be the word "maintenance" which contains the word "main".

This is the referenced parameter: https://github.com/mathieudutour/github-tag-action/blob/master/action.yml#L42-L45

The described behaviour is due to the fact that the String.match method used to match branch names matches for a substring by default: https://github.com/mathieudutour/github-tag-action/blob/master/src/action.ts#L55-L57

Although issues have a low chance of occurrence, it has occurred and has lead to wasted time troubleshooting.

Workaround and Solution A workaround is possible by passing in the argument ^main$,^master$ when invoking the action, but we would prefer keeping as much default behaviour as possible.

The proposed solution is to change the default value of the parameter from "main,master" to "^main$,^master$".

Does this seem acceptable?