Skip to content

Commit 786a607

Browse files
authored
Merge pull request #102 from coding-cpp/fix/98
2 parents 2dd8e7c + 4eed037 commit 786a607

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

.github/workflows/pr.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,22 @@ jobs:
1212
permissions:
1313
contents: read
1414
pull-requests: write
15-
1615
steps:
1716
- name: Checkout
1817
uses: actions/checkout@v3
1918
with:
2019
submodules: recursive
21-
2220
- name: Update and Install dependencies
2321
run: |
2422
sudo apt-get update
2523
sudo apt-get install -y cmake build-essential g++
26-
2724
- name: Build
2825
id: build
2926
run: |
3027
mkdir build
3128
cd build
3229
cmake ..
3330
make
34-
3531
- name: Post success comment
3632
if: ${{ success() }}
3733
uses: actions/github-script@v6
@@ -43,7 +39,6 @@ jobs:
4339
repo: context.repo.repo,
4440
body: 'Build successful! 🎉'
4541
});
46-
4742
- name: Post failure comment
4843
if: ${{ failure() }}
4944
uses: actions/github-script@v6

.github/workflows/version.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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

Comments
 (0)