File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 :
You can’t perform that action at this time.
0 commit comments