Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add version check on PR workflow #102

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,22 @@ jobs:
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Update and Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential g++

- name: Build
id: build
run: |
mkdir build
cd build
cmake ..
make

- name: Post success comment
if: ${{ success() }}
uses: actions/github-script@v6
Expand All @@ -43,7 +39,6 @@ jobs:
repo: context.repo.repo,
body: 'Build successful! 🎉'
});

- name: Post failure comment
if: ${{ failure() }}
uses: actions/github-script@v6
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Version check"

on:
pull_request:
branches:
- main
paths:
- 'include/expresso/version.h'
- 'CMakeLists.txt'
workflow_dispatch:

jobs:
version_check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Extract version from version.h
id: extract_version_h_version
run: |
MAJOR_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_MAJOR )\d+' include/expresso/version.h)
MINOR_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_MINOR )\d+' include/expresso/version.h)
PATCH_VERSION=$(grep -oP '(?<=#define EXPRESSO_VERSION_PATCH )\d+' include/expresso/version.h)
echo "VERSION_H_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" >> $GITHUB_ENV
- name: Extract version from CMakeLists.txt
id: extract_cmake_version
run: |
VERSION=$(grep -oP '(?<=project\(expresso VERSION )\d+\.\d+\.\d+' CMakeLists.txt)
echo "CMAKE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Check version consistency
run: |
if [[ "${{ env.VERSION_H_VERSION }}" != "${{ env.CMAKE_VERSION }}" ]]; then
echo "Version mismatch between version.h and CMakeLists.txt"
exit 1
fi
- name: Post success comment
if: ${{ success() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Version consistency check successful! 🎉'
});
- name: Post failure comment
if: ${{ failure() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Version consistency check failed! ❌'
});
Loading