Skip to content

Commit eebfc24

Browse files
committed
perf: optimize tag fetching - only fetch tags for current commit
Smart tag fetching strategy: 1. Check if tags already exist locally for current commit (skip fetch) 2. If not, use 'git ls-remote' to find which tag points to commit 3. Fetch only that specific tag (not all tags) 4. Fallback to full tag fetch if no match found Benefits: - Zero network calls when tags already present (cache hits) - Minimal network calls when fetching (only the needed tag) - Much faster than 'git fetch --tags' (which fetches all tags)
1 parent b56d600 commit eebfc24

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/build-image.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ jobs:
3838
- name: Compute version
3939
id: version
4040
run: |
41+
# Check if upstream submodule already has tags for current commit
42+
cd upstream/schema-registry
43+
if ! git tag --points-at HEAD | grep -qE '^v?[0-9]+\.[0-9]+\.[0-9]+$'; then
44+
# No tags found locally, fetch only tags for current commit
45+
echo "📦 Fetching tags for submodule commit..."
46+
COMMIT_SHA=$(git rev-parse HEAD)
47+
48+
# Query remote to find which tags point to this commit
49+
MATCHING_TAG=$(git ls-remote --tags origin | grep "$COMMIT_SHA" | grep -oE 'refs/tags/v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
50+
51+
if [ -n "$MATCHING_TAG" ]; then
52+
# Fetch only the specific tag we need
53+
git fetch origin "$MATCHING_TAG:$MATCHING_TAG"
54+
else
55+
# Fallback: fetch all tags if we can't find a specific match
56+
echo "⚠️ No version tag found for commit, fetching all tags..."
57+
git fetch --tags
58+
fi
59+
else
60+
echo "✅ Version tag already available locally"
61+
fi
62+
cd ../..
63+
4164
# Compute version and cache to .version.mk file
4265
echo "🔢 Computing version..."
4366
make version-file

0 commit comments

Comments
 (0)