Skip to content

Commit 4f02d89

Browse files
committed
Refactor tag validation script for clarity and consistency
1 parent 9cdf159 commit 4f02d89

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

.trunk/trunk.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,30 @@ actions:
6666
run: |
6767
#!/usr/bin/env bash
6868
set -e
69+
70+
# Check if we're on main or master branch
6971
if git rev-parse --abbrev-ref HEAD | grep -q 'main\|master'; then
70-
TAG=$(git describe --tags --exact-match "$(git log -n1 --pretty='%h')" 2>/dev/null || echo "")
71-
if [ -z "$TAG" ]; then
72-
echo "No tag found for the current commit. Skipping tag-version check."
72+
# Try to get the tag for the current commit, ignore errors
73+
TAG=$(git describe --tags --exact-match "$(git log -n1 --pretty='%h')" 2>/dev/null || true)
74+
75+
# If no tag found, skip validation entirely
76+
if [ -z "$TAG" ]; then
77+
echo "No tag found for the current commit - skipping version validation."
7378
exit 0
74-
fi
75-
VERSION=$(grep '^version =' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
79+
fi
80+
81+
# Validate it matches pyproject.toml version
82+
VERSION=$(grep '^version =' pyproject.toml | sed -E 's/version = "(.*)"/\1/' 2>/dev/null || echo "")
83+
7684
if [ "$TAG" != "$VERSION" ]; then
7785
echo "Tag '$TAG' does not match version '$VERSION' in pyproject.toml."
7886
exit 1
7987
fi
88+
89+
echo "Tag '$TAG' matches version '$VERSION'."
90+
else
91+
echo "Not on main/master branch - skipping tag validation."
8092
fi
81-
echo "Tag matches version."
8293
exit 0
8394
tools:
8495
enabled:

0 commit comments

Comments
 (0)