Skip to content

Commit b1df57e

Browse files
committed
improve: add format validation and explicit error handling in github-release workflow
1. Add BUILD_INFO format validation before parsing - Validates format: 'bbl_parser <sha> (<date>)' - Uses regex: ^bbl_parser [a-f0-9]+ \([0-9]{4}-[0-9]{2}-[0-9]{2}\)$ - Fails fast with descriptive error if format unexpected - Prevents silent tag generation with incorrect values 2. Replace silenced git operations with explicit error handling - Add conditional logging for git tag creation - Distinguishes between 'tag created' vs 'tag already exists' - Explicit logging for git push with non-fatal fallback - Better debugging when operations fail unexpectedly - Clearer workflow logs with ✅/ℹ️/⚠️ indicators ## Benefits - Robust to vergen format changes (detects issues immediately) - Better observability in workflow logs - Easier future debugging (no more silent failures) - More maintainable: explicit intent vs error suppression
1 parent 1259466 commit b1df57e

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

.github/workflows/github-release.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ jobs:
9999
BUILD_INFO="${{ needs.build.outputs.build_info }}"
100100
echo "build_info=$BUILD_INFO" >> $GITHUB_OUTPUT
101101
102-
# Extract short SHA and date from build info
103-
# Format: "bbl_parser <sha> (<date>)"
102+
# Validate BUILD_INFO format before parsing
103+
# Expected format: "bbl_parser <sha> (<date>)"
104104
# Example: "bbl_parser 14be1ee (2025-12-04)"
105+
if ! echo "$BUILD_INFO" | grep -qE '^bbl_parser [a-f0-9]+ \([0-9]{4}-[0-9]{2}-[0-9]{2}\)$'; then
106+
echo "ERROR: Unexpected BUILD_INFO format: $BUILD_INFO"
107+
exit 1
108+
fi
109+
110+
# Extract short SHA and date from build info
105111
SHORT_SHA=$(echo "$BUILD_INFO" | awk '{print $2}')
106112
DATE=$(echo "$BUILD_INFO" | awk '{print $3}' | tr -d '()')
107113
@@ -116,8 +122,19 @@ jobs:
116122
run: |
117123
git config user.name "github-actions"
118124
git config user.email "github-actions@github.com"
119-
git tag "${{ steps.release_info.outputs.tag_name }}" || true
120-
git push origin "${{ steps.release_info.outputs.tag_name }}" 2>/dev/null || true
125+
TAG_NAME="${{ steps.release_info.outputs.tag_name }}"
126+
127+
if git tag "$TAG_NAME"; then
128+
echo "✅ Tag created: $TAG_NAME"
129+
else
130+
echo "ℹ️ Tag already exists: $TAG_NAME"
131+
fi
132+
133+
if git push origin "$TAG_NAME" 2>&1; then
134+
echo "✅ Tag pushed successfully"
135+
else
136+
echo "⚠️ Tag push failed (may already exist in remote)"
137+
fi
121138
122139
- name: Determine release name
123140
id: release_name

0 commit comments

Comments
 (0)