Skip to content

feat: add TAG_FROM_BRANCH to derive the tag from the release branch name#360

Open
postalservice14 wants to merge 1 commit into
anothrNick:masterfrom
postalservice14:feat/tag-from-branch
Open

feat: add TAG_FROM_BRANCH to derive the tag from the release branch name#360
postalservice14 wants to merge 1 commit into
anothrNick:masterfrom
postalservice14:feat/tag-from-branch

Conversation

@postalservice14

Copy link
Copy Markdown

Summary of changes

Adds an opt-in TAG_FROM_BRANCH option (default false) that takes the tag verbatim from the release version embedded in the branch name, instead of bumping via #major/#minor/#patch tokens or DEFAULT_BUMP.

  • Reads the version from the merge/squash commit message first, then falls back to the current branch name (covers both merge-to-main and running directly on a release/X.Y.Z branch).
  • New BRANCH_VERSION_REGEX (default release[/-]([0-9]+\.[0-9]+\.[0-9]+)) makes the pattern configurable; it must contain exactly one capture group for the X.Y.Z. The WITH_V/TAG_PREFIX prefix is applied to the captured version.
  • If no version can be recovered (e.g. a rebase-merge dropped the branch name) the action fails loudly rather than producing a wrong tag.
  • CUSTOM_TAG keeps precedence if both are set.
  • Matching uses bash [[ =~ ]] / 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-false flag and slots in before the existing case "$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.bats13/13 pass (6 new + 7 existing).
  • New tests cover: merge-commit message, squash-merge message, current-branch fallback, existing prefixed tag as base, the loud-failure rebase guard, and a custom BRANCH_VERSION_REGEX.
  • shellcheck entrypoint.sh — clean on the diff.

List any unknowns

  • Whether hotfix/* (and similar) should be matched by the default regex, or left for users to set via BRANCH_VERSION_REGEX. Current default targets release/ and release- only.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TAG_FROM_BRANCH — derive the tag from the release branch name

1 participant