Skip to content

Commit

Permalink
(fix): use non-release-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Nov 14, 2024
1 parent 9bd790a commit ff5fde4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ci/scripts/towncrier_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import argparse
import re
import subprocess
from typing import TYPE_CHECKING

Expand All @@ -20,6 +21,10 @@ class NoPatchReleaseOnMainError(Exception):
pass


class NoMinorMajorReleaseOffMainError(Exception):
pass


def parse_args(argv: Sequence[str] | None = None) -> Args:
parser = argparse.ArgumentParser(
prog="towncrier-automation",
Expand Down Expand Up @@ -66,9 +71,16 @@ def main(argv: Sequence[str] | None = None) -> None:
text=True,
check=True,
).stdout.strip()
if Version(args.version).micro != 0 and base_branch == "main":
patch_branch_pattern = r"\d+\.\d+\.x"
if Version(args.version).micro != 0 and not re.fullmatch(
patch_branch_pattern, base_branch
):
raise NoPatchReleaseOnMainError(
f"Version {args.version} is a patch release, but you are trying to release from main branch."
f"Version {args.version} is a patch release, but you are trying to release from a non-patch release branch: {base_branch}."
)
if Version(args.version).micro == 0 and base_branch != "main":
raise NoMinorMajorReleaseOffMainError(
f"Version {args.version} is a minor or major release, but you are trying to release not from main: {base_branch}."
)
pr_description = (
"" if base_branch == "main" else "@meeseeksmachine backport to main"
Expand Down

0 comments on commit ff5fde4

Please sign in to comment.