feat: add TAG_FROM_BRANCH to derive the tag from the release branch name#360
Open
postalservice14 wants to merge 1 commit into
Open
feat: add TAG_FROM_BRANCH to derive the tag from the release branch name#360postalservice14 wants to merge 1 commit into
postalservice14 wants to merge 1 commit into
Conversation
Adds an opt-in TAG_FROM_BRANCH option (default false) that takes the tag verbatim from the release version embedded in the branch name, read from the merge/squash commit message and falling back to the current branch name. A configurable BRANCH_VERSION_REGEX (default release[/-](X.Y.Z)) extracts the version, and the WITH_V/TAG_PREFIX prefix is applied. When no version can be recovered (e.g. a rebase-merge dropped the branch name) the action fails loudly instead of producing a wrong tag. CUSTOM_TAG keeps precedence. Matching uses bash [[ =~ ]] / BASH_REMATCH, so untrusted commit text is never interpolated into a shell command. Documents both options in the README and adds bats coverage for the merge-commit, squash, branch-name fallback, existing-tag base, rebase guard, and custom-regex paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Adds an opt-in
TAG_FROM_BRANCHoption (defaultfalse) that takes the tag verbatim from the release version embedded in the branch name, instead of bumping via#major/#minor/#patchtokens orDEFAULT_BUMP.mainand running directly on arelease/X.Y.Zbranch).BRANCH_VERSION_REGEX(defaultrelease[/-]([0-9]+\.[0-9]+\.[0-9]+)) makes the pattern configurable; it must contain exactly one capture group for theX.Y.Z. TheWITH_V/TAG_PREFIXprefix is applied to the captured version.CUSTOM_TAGkeeps precedence if both are set.[[ =~ ]]/BASH_REMATCH, so untrusted commit text is never interpolated into a shell command.Both options are documented in the README Options section.
Closes #359
Breaking Changes
Do any of the included changes break current behaviour or configuration?
(YES / NO) — the feature is gated behind a default-
falseflag and slots in before the existingcase "$log"bump path, so every current workflow behaves identically. No outputs changed.How changes have been tested
bats test/test_branch_tag.bats test/test_prefix.bats→ 13/13 pass (6 new + 7 existing).BRANCH_VERSION_REGEX.shellcheck entrypoint.sh— clean on the diff.List any unknowns
hotfix/*(and similar) should be matched by the default regex, or left for users to set viaBRANCH_VERSION_REGEX. Current default targetsrelease/andrelease-only.