Repository navigation
103 lines (81 loc) · 3.77 KB
/
Copy pathversion-sync.yml
File metadata and controls
103 lines (81 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Version Sync Check
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
version-sync:
name: Version Sync Validation
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check version consistency
run: |
# Extract version from code
VERSION_CODE=$(grep '^[[:space:]]*Version[[:space:]]*=' cmd/g8s/version.go | head -1 | sed 's/.*= *"\([^"]*\)".*/\1/')
# Extract latest version from CHANGELOG
VERSION_CHANGELOG=$(awk '/^## \[Unreleased\]/ {found=1; next} found && /^## \[/ {print $2; exit}' CHANGELOG.md | tr -d '[]')
echo "Code version: $VERSION_CODE"
echo "CHANGELOG version: $VERSION_CHANGELOG"
if [ -z "$VERSION_CODE" ] || [ -z "$VERSION_CHANGELOG" ]; then
echo "::error::Could not extract versions"
exit 1
fi
if [ "$VERSION_CODE" != "$VERSION_CHANGELOG" ]; then
echo "::error::Version mismatch: code=$VERSION_CODE, changelog=$VERSION_CHANGELOG"
exit 1
fi
# Check if tag exists for this version
if git rev-parse "refs/tags/v$VERSION_CODE" >/dev/null 2>&1; then
echo "Tag v$VERSION_CODE exists locally"
fi
echo "✓ Version sync OK"
- name: Check packaging installer version drift
run: |
# Packaging templates must not pin a stale release version (#319).
# ci.yml derives the live version at build time; these literals are
# the offline fallback defaults and the chocolatey download URL.
VERSION_CODE=$(grep '^[[:space:]]*Version[[:space:]]*=' cmd/g8s/version.go | head -1 | sed 's/.*= *"\([^"]*\)".*/\1/')
fail=0
for f in packaging/windows/g8s.nsi packaging/windows/g8s.wxs; do
LITERAL=$(grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' "$f" | head -1 | tr -d '"')
echo "$f: $LITERAL"
if [ "$LITERAL" != "$VERSION_CODE" ]; then
echo "::error::Installer template version drift in $f: template=$LITERAL, canonical=$VERSION_CODE"
fail=1
fi
done
CHOCO_VER=$(grep -oE 'download/v[0-9]+\.[0-9]+\.[0-9]+/' packaging/chocolatey/tools/chocolateyinstall.ps1 | head -1 | sed 's|download/v||; s|/$||')
echo "chocolateyinstall.ps1: v$CHOCO_VER"
if [ "$CHOCO_VER" != "$VERSION_CODE" ]; then
echo "::error::Chocolatey download URL drift: url=v$CHOCO_VER, canonical=$VERSION_CODE"
fail=1
fi
if [ "$fail" -ne 0 ]; then
exit 1
fi
echo "✓ Packaging version consistent"
- name: Check Go version consistency
run: |
GO_MOD_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
WORKFLOW_VERSION=$(grep -h "go-version:" .github/workflows/*.yml 2>/dev/null | head -1 | sed "s/.*go-version: '\([^']*\)'.*/\1/")
echo "go.mod version: $GO_MOD_VERSION"
echo "Workflow version: $WORKFLOW_VERSION"
if [ -z "$GO_MOD_VERSION" ] || [ -z "$WORKFLOW_VERSION" ]; then
echo "::warning::Could not extract Go versions"
exit 0
fi
GO_MOD_MAJOR_MINOR=$GO_MOD_VERSION
if [ "$GO_MOD_MAJOR_MINOR" != "$WORKFLOW_VERSION" ]; then
echo "::error::Go version mismatch: go.mod=$GO_MOD_VERSION (normalized: $GO_MOD_MAJOR_MINOR), workflows=$WORKFLOW_VERSION"
exit 1
fi
echo "✓ Go version consistent"
- name: Run CI version sync check script
run: bash tools/ci_version_sync_check.sh