From 00a17dea89b123a3cbe5482922fec9ab7e21996e Mon Sep 17 00:00:00 2001 From: koval Date: Mon, 8 Jun 2026 11:38:27 +0300 Subject: [PATCH] implemented --- .github/scripts/autorelease.py | 27 ++++++++++++++++++++------- .github/workflows/autorelease.yml | 1 + .github/workflows/python-linters.yml | 2 +- .github/workflows/python-tests.yml | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/scripts/autorelease.py b/.github/scripts/autorelease.py index a551364..c6c7bc8 100644 --- a/.github/scripts/autorelease.py +++ b/.github/scripts/autorelease.py @@ -46,17 +46,30 @@ def get_release_tags(github_token: str) -> List[str]: params["page"] += 1 -def main(github_token: str, current_branch: str) -> None: - branch_pattern = r"^v(?P\d+)$" - branch_matching = re.match(branch_pattern, current_branch, re.I) - if not branch_matching: - logger.info("Branch %s is not a valid release branch", current_branch) - return +RELEASE_BRANCH = "master" +LEGACY_BRANCH_PATTERN = re.compile(r"^v(?P\d+)$", re.I) + + +def get_major_release(current_branch: str, project_version_str: str) -> Optional[str]: + if current_branch == RELEASE_BRANCH: + return str(Version(project_version_str).major) + + branch_matching = LEGACY_BRANCH_PATTERN.match(current_branch) + if branch_matching: + return branch_matching.group("major_release") - major_release = branch_matching.group("major_release") + return None + + +def main(github_token: str, current_branch: str) -> None: project_version_str = get_project_version() logger.info("Project version %s", project_version_str) + major_release = get_major_release(current_branch, project_version_str) + if major_release is None: + logger.info("Branch %s is not a valid release branch", current_branch) + return + if not project_version_str.startswith(major_release): logger.info( "Release tag %s is invalid, major releases in the %s branch must start with %s", diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml index ae3ab03..ec7cfb9 100644 --- a/.github/workflows/autorelease.yml +++ b/.github/workflows/autorelease.yml @@ -3,6 +3,7 @@ name: Autorelease on: pull_request: types: [ closed ] + branches: [ master, v2 ] jobs: autorelease: diff --git a/.github/workflows/python-linters.yml b/.github/workflows/python-linters.yml index c4a4f53..eedbec2 100644 --- a/.github/workflows/python-linters.yml +++ b/.github/workflows/python-linters.yml @@ -3,7 +3,7 @@ name: Linters on: push: pull_request: - branches: [ master ] + branches: [ master, v2 ] jobs: build: diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 40b1222..6e82481 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -3,7 +3,7 @@ name: Tests on: push: pull_request: - branches: [ master ] + branches: [ master, v2 ] jobs: test: