1+ name : " Version check"
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ paths :
8+ - ' include/expresso/version.h'
9+ - ' CMakeLists.txt'
10+ workflow_dispatch :
11+
12+ jobs :
13+ version_check :
14+ runs-on : ubuntu-latest
15+ permissions :
16+ contents : read
17+ pull-requests : write
18+ steps :
19+ - name : Checkout
20+ uses : actions/checkout@v3
21+ with :
22+ submodules : recursive
23+ - name : Extract version from version.h
24+ id : extract_version_h_version
25+ run : |
26+ MAJOR_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_MAJOR )\d+' include/expresso/version.h)
27+ MINOR_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_MINOR )\d+' include/expresso/version.h)
28+ PATCH_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_PATCH )\d+' include/expresso/version.h)
29+ echo "VERSION_H_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" >> $GITHUB_ENV
30+ - name : Extract version from CMakeLists.txt
31+ id : extract_cmake_version
32+ run : |
33+ VERSION=$(grep -oP '(?<=project\(expresso VERSION )\d+\.\d+\.\d+' CMakeLists.txt)
34+ echo "CMAKE_VERSION=$VERSION" >> $GITHUB_ENV
35+ - name : Check version consistency
36+ run : |
37+ if [[ "${{ env.VERSION_H_VERSION }}" != "${{ env.CMAKE_VERSION }}" ]]; then
38+ echo "Version mismatch between version.h and CMakeLists.txt"
39+ exit 1
40+ fi
41+ - name : Post success comment
42+ if : ${{ success() }}
43+ uses : actions/github-script@v6
44+ with :
45+ script : |
46+ github.rest.issues.createComment({
47+ issue_number: context.issue.number,
48+ owner: context.repo.owner,
49+ repo: context.repo.repo,
50+ body: 'Version consistency check successful! 🎉'
51+ });
52+ - name : Post failure comment
53+ if : ${{ failure() }}
54+ uses : actions/github-script@v6
55+ with :
56+ script : |
57+ github.rest.issues.createComment({
58+ ...context.repo,
59+ issue_number: context.issue.number,
60+ owner: context.repo.owner,
61+ repo: context.repo.repo,
62+ body: 'Version consistency check failed! ❌'
63+ });
0 commit comments