Skip to content

Commit 67fa6de

Browse files
committed
ci(release): guard against tag/CMakeLists VERSION drift
Mirrors the same guard added to polymarket-cpp + open-meteo-cpp this hour. Fails the release job (before publishing) if the tag X.Y.Z disagrees with the project(...) VERSION field in CMakeLists.txt. The drift was a real shipped bug in 2 of the 6 sibling SDKs: polymarket-cpp v0.1.1/v0.1.2/v0.1.3/v0.1.4 and open-meteo-cpp v0.1.1/v0.1.2 all tagged with the project VERSION still on 0.1.0. This repo is currently in sync but the same drift could happen on any future release without the guard.
1 parent 898c594 commit 67fa6de

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25+
- name: Verify tag matches CMakeLists project VERSION
26+
# Pin the source-of-truth: the tag X.Y.Z must equal the
27+
# `project(ncei-cpp VERSION X.Y.Z ...)` field in
28+
# CMakeLists.txt. Without this guard the two can drift
29+
# silently and corrupt `find_package(ncei-cpp VERSION
30+
# X.Y.Z)` consumer queries (the generated
31+
# ncei-cppConfigVersion.cmake tracks PROJECT_VERSION).
32+
run: |
33+
tag="${GITHUB_REF#refs/tags/}"
34+
version="${tag#v}"
35+
cmake_version=$(awk -F 'VERSION |LANGUAGES' '
36+
/^project\(ncei-cpp / { gsub(/[ \t]/,"",$2); print $2; exit }
37+
' CMakeLists.txt)
38+
if [ "$cmake_version" != "$version" ]; then
39+
echo "::error::tag $tag implies version '$version' but CMakeLists.txt says '$cmake_version'" >&2
40+
echo "Bump 'project(ncei-cpp VERSION ...)' to match before tagging." >&2
41+
exit 1
42+
fi
43+
echo "OK: tag $tag matches CMakeLists VERSION $cmake_version"
44+
2545
- name: Extract release notes from CHANGELOG.md
2646
run: |
2747
tag="${GITHUB_REF#refs/tags/}"

0 commit comments

Comments
 (0)