Skip to content

Commit 6973660

Browse files
authored
Merge pull request #2 from redis-developer/fix-tag-resolution
Fix tag parsing for milestone tags
2 parents 4309598 + 15d01b0 commit 6973660

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

src/redis_release/orchestrator.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Main orchestration logic for Redis release automation."""
2-
2+
import re
33
from dataclasses import dataclass
44
from typing import Optional
55

@@ -11,7 +11,6 @@
1111
PackageType,
1212
ReleaseState,
1313
ReleaseType,
14-
WorkflowConclusion,
1514
WorkflowRun,
1615
)
1716
from .state_manager import StateManager
@@ -94,13 +93,14 @@ def _get_docker_branch(self, tag: str) -> str:
9493
Returns:
9594
Branch name to use for workflow trigger
9695
"""
97-
# extract major.minor version from tag
96+
# Extract major.minor version from tag
9897
# examples: "8.2.1" -> "8.2", "8.4-m01" -> "8.4"
99-
if "." in tag:
100-
parts = tag.split(".")
101-
if len(parts) >= 2:
102-
major_minor = f"{parts[0]}.{parts[1]}"
103-
return f"release/{major_minor}"
98+
match = re.match(r"^(\d+)\.(\d+)", tag)
99+
if match:
100+
major = match.group(1)
101+
minor = match.group(2)
102+
major_minor = f"{major}.{minor}"
103+
return f"release/{major_minor}"
104104

105105
console.print(
106106
f"[yellow]Warning: Could not determine branch for tag '{tag}', using 'main'[/yellow]"
@@ -219,7 +219,7 @@ def execute_release(
219219
self._print_completed_state_phase(
220220
phase_completed=docker_state.build_completed if docker_state else False,
221221
workflow=docker_state.build_workflow if docker_state else None,
222-
name="Build"
222+
name="Build",
223223
)
224224

225225
state_manager.save_state(state)
@@ -236,7 +236,7 @@ def execute_release(
236236
self._print_completed_state_phase(
237237
phase_completed=docker_state.publish_completed if docker_state else False,
238238
workflow=docker_state.publish_workflow if docker_state else None,
239-
name="Publish"
239+
name="Publish",
240240
)
241241

242242
state_manager.save_state(state)
@@ -315,7 +315,7 @@ def _execute_build_phase(
315315
state=state,
316316
repo=repo,
317317
orchestrator_config=self.docker_config,
318-
timeout_minutes=45
318+
timeout_minutes=45,
319319
)
320320

321321
executor = PhaseExecutor()
@@ -338,7 +338,7 @@ def _execute_publish_phase(
338338
state=state,
339339
repo=repo,
340340
orchestrator_config=self.docker_config,
341-
timeout_minutes=30 # Publish might be faster than build
341+
timeout_minutes=30, # Publish might be faster than build
342342
)
343343

344344
executor = PhaseExecutor()

src/redis_release/workflow_executor.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
"""Workflow execution classes for Redis release automation."""
2+
import re
23
import json
34
from abc import ABC, abstractmethod
45
from typing import Any, Dict, Optional
56

67
from rich.console import Console
78

89
from .github_client import GitHubClient
9-
from .models import PackageState, PackageType, ReleaseState, WorkflowConclusion, WorkflowRun
10+
from .models import (
11+
PackageState,
12+
PackageType,
13+
ReleaseState,
14+
WorkflowConclusion,
15+
WorkflowRun,
16+
)
1017

1118
console = Console()
1219

@@ -19,7 +26,7 @@ def __init__(
1926
state: ReleaseState,
2027
repo: str,
2128
orchestrator_config: Dict[str, Any],
22-
timeout_minutes: int = 45
29+
timeout_minutes: int = 45,
2330
):
2431
self.state = state
2532
self.repo = repo
@@ -94,26 +101,25 @@ def extract_result(self, github_client: GitHubClient, artifacts: Dict[str, Dict[
94101
def _get_release_branch(self) -> str:
95102
"""Get the release branch based on the release tag.
96103
97-
Extracts major.minor from tag (e.g., "8.2.1" -> "release/8.2").
104+
Extracts major.minor from tag (e.g., "8.2.1" -> "release/8.2", "8.4-m01-int" -> "release/8.4").
98105
99106
Returns:
100107
Release branch name
101108
102109
Raises:
103110
ValueError: If tag format is invalid
104111
"""
105-
tag_parts = self.state.tag.split(".")
106-
if len(tag_parts) < 2:
107-
raise ValueError(f"Invalid tag format '{self.state.tag}': expected at least major.minor version")
108-
109-
try:
110-
# Validate that major and minor are numeric
111-
int(tag_parts[0])
112-
int(tag_parts[1])
113-
except ValueError:
114-
raise ValueError(f"Invalid tag format '{self.state.tag}': major and minor versions must be numeric")
112+
# Extract major.minor version from the beginning of the tag
113+
# This handles both "8.2.1" and "8.4-m01-int" formats
114+
match = re.match(r"^(\d+)\.(\d+)", self.state.tag)
115+
if not match:
116+
raise ValueError(
117+
f"Invalid tag format '{self.state.tag}': expected tag to start with major.minor version (e.g., '8.2.1' or '8.4-m01')"
118+
)
115119

116-
major_minor = f"{tag_parts[0]}.{tag_parts[1]}"
120+
major = match.group(1)
121+
minor = match.group(2)
122+
major_minor = f"{major}.{minor}"
117123
return f"release/{major_minor}"
118124

119125

0 commit comments

Comments
 (0)