Skip to content

Commit 0c2ead5

Browse files
dannyrobertsclaude
andcommitted
Select best commcare-core patch branch for release builds
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f2c2b44 commit 0c2ead5

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/release-build.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,24 @@ jobs:
4242
MAJOR_MINOR=${VERSION%.*}
4343
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
4444
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
45-
echo "CCCORE_BRANCH=commcare_$MAJOR_MINOR" >> "$GITHUB_ENV"
45+
46+
# Find the best commcare-core branch: highest commcare_X.Y.Z <= current version,
47+
# falling back to commcare_X.Y
48+
PATCH=${VERSION##*.}
49+
# Strip any trailing letters to get the numeric patch for comparison
50+
PATCH_NUM=$(echo "$PATCH" | sed 's/[^0-9].*//')
51+
BEST_BRANCH="commcare_$MAJOR_MINOR"
52+
BEST_PATCH=-1
53+
while IFS=$'\t' read -r _sha ref; do
54+
branch=${ref#refs/heads/}
55+
branch_patch=${branch##*.}
56+
if [[ "$branch_patch" =~ ^[0-9]+$ ]] && (( branch_patch <= PATCH_NUM )) && (( branch_patch > BEST_PATCH )); then
57+
BEST_BRANCH="$branch"
58+
BEST_PATCH=$branch_patch
59+
fi
60+
done < <(git ls-remote --heads https://github.com/dimagi/commcare-core.git "commcare_${MAJOR_MINOR}.*")
61+
echo "Selected commcare-core branch: $BEST_BRANCH"
62+
echo "CCCORE_BRANCH=$BEST_BRANCH" >> "$GITHUB_ENV"
4663
- name: Checkout commcare-android
4764
uses: actions/checkout@v6
4865
with:

0 commit comments

Comments
 (0)