Skip to content

Commit 00a17de

Browse files
author
koval
committed
implemented
1 parent a450ae4 commit 00a17de

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

.github/scripts/autorelease.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,30 @@ def get_release_tags(github_token: str) -> List[str]:
4646
params["page"] += 1
4747

4848

49-
def main(github_token: str, current_branch: str) -> None:
50-
branch_pattern = r"^v(?P<major_release>\d+)$"
51-
branch_matching = re.match(branch_pattern, current_branch, re.I)
52-
if not branch_matching:
53-
logger.info("Branch %s is not a valid release branch", current_branch)
54-
return
49+
RELEASE_BRANCH = "master"
50+
LEGACY_BRANCH_PATTERN = re.compile(r"^v(?P<major_release>\d+)$", re.I)
51+
52+
53+
def get_major_release(current_branch: str, project_version_str: str) -> Optional[str]:
54+
if current_branch == RELEASE_BRANCH:
55+
return str(Version(project_version_str).major)
56+
57+
branch_matching = LEGACY_BRANCH_PATTERN.match(current_branch)
58+
if branch_matching:
59+
return branch_matching.group("major_release")
5560

56-
major_release = branch_matching.group("major_release")
61+
return None
62+
63+
64+
def main(github_token: str, current_branch: str) -> None:
5765
project_version_str = get_project_version()
5866
logger.info("Project version %s", project_version_str)
5967

68+
major_release = get_major_release(current_branch, project_version_str)
69+
if major_release is None:
70+
logger.info("Branch %s is not a valid release branch", current_branch)
71+
return
72+
6073
if not project_version_str.startswith(major_release):
6174
logger.info(
6275
"Release tag %s is invalid, major releases in the %s branch must start with %s",

.github/workflows/autorelease.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Autorelease
33
on:
44
pull_request:
55
types: [ closed ]
6+
branches: [ master, v2 ]
67

78
jobs:
89
autorelease:

.github/workflows/python-linters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Linters
33
on:
44
push:
55
pull_request:
6-
branches: [ master ]
6+
branches: [ master, v2 ]
77

88
jobs:
99
build:

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on:
44
push:
55
pull_request:
6-
branches: [ master ]
6+
branches: [ master, v2 ]
77

88
jobs:
99
test:

0 commit comments

Comments
 (0)