Skip to content

Commit c4d27b7

Browse files
committed
ci: Verify release tag matches binary version
1 parent c4578af commit c4d27b7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20+
- name: Validate tag matches version in main.go
21+
run: |
22+
# Extract version from main.go
23+
VERSION=$(grep -E '^[[:space:]]*version[[:space:]]*=' main.go | sed -E 's/.*"([^"]+)".*/\1/')
24+
25+
# Get the tag name (remove refs/tags/ prefix)
26+
TAG_NAME=${GITHUB_REF#refs/tags/}
27+
28+
# Remove 'v' prefix from tag if present
29+
TAG_VERSION=${TAG_NAME#v}
30+
31+
echo "Version in main.go: $VERSION"
32+
echo "Tag version: $TAG_VERSION"
33+
34+
# Compare versions
35+
if [ "$VERSION" != "$TAG_VERSION" ]; then
36+
echo "ERROR: Tag version ($TAG_VERSION) does not match version in main.go ($VERSION)"
37+
echo "Please ensure the tag matches the version defined in main.go"
38+
exit 1
39+
fi
40+
41+
echo "✅ Tag version matches main.go version: $VERSION"
42+
2043
- name: Set up Go 1.23
2144
uses: actions/setup-go@v4
2245
with:

0 commit comments

Comments
 (0)