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
27 changes: 20 additions & 7 deletions .github/scripts/autorelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<major_release>\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<major_release>\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",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Autorelease
on:
pull_request:
types: [ closed ]
branches: [ master, v2 ]

jobs:
autorelease:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Linters
on:
push:
pull_request:
branches: [ master ]
branches: [ master, v2 ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on:
push:
pull_request:
branches: [ master ]
branches: [ master, v2 ]

jobs:
test:
Expand Down
Loading