Skip to content

Commit 33149ea

Browse files
authored
Add new CI job to verify version in files match Git tag name (#61)
This commit adds a new job to the GitHub Actions workflow that verifies that the version specified in the CMakeLists.txt and vcpkg.json files matches the version from Git tag name. It will run only when a tag is pushed.
1 parent a153878 commit 33149ea

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/ubuntu.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,27 @@ jobs:
165165
path: install
166166
retention-days: 7
167167
continue-on-error: true
168+
169+
# Verify release (tag push)
170+
release-tests:
171+
if: startsWith(github.ref, 'refs/tags/v')
172+
runs-on: ubuntu-latest
173+
steps:
174+
- name: Checkout repository
175+
uses: actions/checkout@v4
176+
177+
- name: Verify versions
178+
run: |
179+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
180+
CMAKE_VERSION=$(tr -d '\n' < CMakeLists.txt | grep -oP 'project\([^()]*VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
181+
VCPKG_VERSION=$(jq -r '.version' vcpkg.json)
182+
183+
if [[ "$TAG_VERSION" != "$CMAKE_VERSION" ]]; then
184+
echo "::error::Git tag version ($TAG_VERSION) does not match CMakeLists.txt version ($CMAKE_VERSION)"
185+
EXIT_CODE=1
186+
fi
187+
if [[ "$TAG_VERSION" != "$VCPKG_VERSION" ]]; then
188+
echo "::error::Git tag version ($TAG_VERSION) does not match vcpkg.json version ($VCPKG_VERSION)"
189+
EXIT_CODE=1
190+
fi
191+
exit $EXIT_CODE

0 commit comments

Comments
 (0)