Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ jobs:
if: github.event_name == 'pull_request' && steps.already_released.outputs.value != 'true'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
PR_BODY_FILE=$(mktemp)
printf '%s' "$PR_BODY" > "$PR_BODY_FILE"
python3 scripts/release/bump_version.py \
--title "$PR_TITLE" \
--body-file "$PR_BODY_FILE" \
--output "$GITHUB_OUTPUT"

- name: Determine version bump (manual)
Expand Down
20 changes: 5 additions & 15 deletions scripts/release/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def find_latest_semver_tag() -> str:
return "{}.{}.{}".format(*versions[-1])


def determine_bump_type(title: str, body: str) -> str:
def determine_bump_type(title: str) -> str:
# Breaking changes are signalled only by the `!` marker in the title
# (e.g. `feat!:`). Free-text body/title prose is not trusted: a PR that
# merely mentions "BREAKING CHANGE" must not force a major bump.
title = title.strip()
body = body.strip()
breaking_re = re.compile(r"BREAKING[ -]CHANGES?", re.IGNORECASE)
if breaking_re.search(title) or breaking_re.search(body):
return "major"
match = re.match(r"^([a-zA-Z]+)(\([^)]+\))?(!)?:", title)
if not match:
return "none"
Expand Down Expand Up @@ -119,12 +118,6 @@ def parse_bool(value: str) -> bool:
return value.strip().lower() == "true"


def resolve_body(args: argparse.Namespace) -> str:
if args.body_file:
return Path(args.body_file).read_text(encoding="utf-8")
return args.body or ""


def write_outputs(output_path: str, entries: dict[str, str]) -> None:
if not output_path:
for key, value in entries.items():
Expand All @@ -138,8 +131,6 @@ def write_outputs(output_path: str, entries: dict[str, str]) -> None:
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--title", default="")
parser.add_argument("--body", default="")
parser.add_argument("--body-file", dest="body_file", default="")
parser.add_argument("--output", default="")
parser.add_argument("--manual-bump", dest="manual_bump", default="")
parser.add_argument(
Expand Down Expand Up @@ -174,8 +165,7 @@ def main() -> int:
)
return 0

body = resolve_body(args)
bump = determine_bump_type(args.title, body)
bump = determine_bump_type(args.title)
if bump == "none":
write_outputs(
args.output,
Expand Down
Loading