Skip to content

Commit 4eed037

Browse files
committed
make version check separate workflow
1 parent 4ef67c5 commit 4eed037

File tree

2 files changed

+63
-52
lines changed

2 files changed

+63
-52
lines changed

.github/workflows/pr.yaml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,6 @@ on:
77
workflow_dispatch:
88

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

.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)