Skip to content
Merged
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
19 changes: 10 additions & 9 deletions .github/scripts/release-branch-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

set -e

# Regex pattern for valid release branch names (release/X.Y.Z)
RELEASE_BRANCH_PATTERN='^release/[0-9]+\.[0-9]+\.[0-9]+$'
# Regex pattern for valid release branch names (release/X.Y.Z or release/X.Y.Z-ota)
RELEASE_BRANCH_PATTERN='^release/[0-9]+\.[0-9]+\.[0-9]+(-ota)?$'

# -----------------------------------------------------------------------------
# Helper Functions
Expand Down Expand Up @@ -71,10 +71,10 @@ pr_exists() {
[[ "$existing_pr" -gt 0 ]]
}

# Parse version from release branch name (release/X.Y.Z -> X.Y.Z)
# Parse version from release branch name (release/X.Y.Z or release/X.Y.Z-ota -> X.Y.Z)
parse_version() {
local branch=$1
echo "$branch" | sed 's|release/||'
echo "$branch" | sed 's|release/||' | sed 's|-ota$||'
}

# Compare two semantic versions
Expand Down Expand Up @@ -107,14 +107,15 @@ get_active_release_branches() {
local branches=""

# Query open and draft PRs with title starting with "release:" (case-insensitive)
# The jq filter extracts version from PR titles like "release: 7.36.0" or "Release: 7.36.0 (#1234)"
# The jq filter extracts version from PR titles like "release: 7.36.0", "Release: 7.36.0 (#1234)",
# or OTA variants like "release: 7.81.1-ota"
local pr_data
pr_data=$(gh pr list \
--state open \
--limit 500 \
--search 'in:title release' \
--json title,isDraft \
--jq '.[] | select(.title | test("^release:\\s*[0-9]+\\.[0-9]+\\.[0-9]+"; "i")) | .title' \
--jq '.[] | select(.title | test("^release:\\s*[0-9]+\\.[0-9]+\\.[0-9]+(-ota)?"; "i")) | .title' \
2>/dev/null || echo "")

if [[ -z "$pr_data" ]]; then
Expand All @@ -125,11 +126,11 @@ get_active_release_branches() {
# Extract version numbers from PR titles and convert to branch names
while IFS= read -r title; do
if [[ -n "$title" ]]; then
# Extract version (X.Y.Z) from title - jq already validated the format,
# so we just need to extract the first semantic version pattern.
# Extract version (X.Y.Z or X.Y.Z-ota) from title - jq already validated the format,
# so we just need to extract the first semantic version pattern (with optional -ota suffix).
# Using grep -oE is case-agnostic and simpler than matching "release:" variations.
local version
version=$(echo "$title" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
version=$(echo "$title" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+(-ota)?' | head -1)
if [[ -n "$version" ]]; then
local branch="release/${version}"
# Only add if not already in list (use grep -Fx for exact string matching,
Expand Down