Skip to content

Commit 336c289

Browse files
authored
Harden validate-yaml release-build lockfile detection in CGO workflow (#38112)
1 parent 1c7098b commit 336c289

2 files changed

Lines changed: 249 additions & 95 deletions

File tree

.github/workflows/cgo.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,20 @@ jobs:
520520
# Track if any release-compiled files are found
521521
FOUND_RELEASE=0
522522
523-
# Check each file for version numbers in the header
523+
# Check each file for release-build markers.
524524
# Release builds include version like: "# This file was automatically generated by gh-aw (v1.0.0). DO NOT EDIT."
525525
# Dev builds do not: "# This file was automatically generated by gh-aw. DO NOT EDIT."
526526
for file in $LOCK_FILES; do
527-
# Look for the pattern: "by gh-aw (v" or "by gh-aw (0" or similar version patterns
528-
# This matches versions like (v1.0.0), (0.1.0), etc.
529-
if grep -E '# This file was automatically generated by gh-aw \([v0-9]' "$file" > /dev/null 2>&1; then
527+
# Release-compiled lock files can be identified by either:
528+
# 1. Header marker with version suffix (legacy): "...generated by gh-aw (vX.Y.Z)."
529+
# 2. Metadata marker: compiler_version field in gh-aw-metadata.
530+
HEADER_MARKER=$(grep -E '^# This file was automatically generated by gh-aw \([v0-9]' "$file" || true)
531+
METADATA_MARKER=$(grep -E '^# gh-aw-metadata: .*"compiler_version":' "$file" || true)
532+
if [ -n "$HEADER_MARKER$METADATA_MARKER" ]; then
530533
echo "❌ ERROR: Found release-compiled lock file: $file"
531534
echo ""
532-
echo "Header line:"
533-
grep -E '# This file was automatically generated by gh-aw \([v0-9]' "$file" || true
535+
echo "Release-build marker(s):"
536+
printf '%s\n%s\n' "$HEADER_MARKER" "$METADATA_MARKER" | sed '/^$/d'
534537
echo ""
535538
FOUND_RELEASE=1
536539
fi
@@ -541,7 +544,7 @@ jobs:
541544
echo "💡 Lock files should NOT be compiled with a release build!"
542545
echo ""
543546
echo "Lock files in the repository must be compiled with development builds."
544-
echo "Release builds include version numbers in the header, which should only"
547+
echo "Release builds include version markers (header or metadata), which should only"
545548
echo "appear in released binaries, not in source-controlled workflow files."
546549
echo ""
547550
echo "To fix:"
@@ -555,7 +558,7 @@ jobs:
555558
exit 1
556559
fi
557560
558-
echo "✅ All lock files compiled with development build (no version in header)"
561+
echo "✅ All lock files compiled with development build (no release markers)"
559562
560563
- name: Check skill file URLs use main branch
561564
run: |

0 commit comments

Comments
 (0)