diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 45fe183..982ae24 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -12,18 +12,15 @@ 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: | @@ -31,7 +28,6 @@ jobs: cd build cmake .. make - - name: Post success comment if: ${{ success() }} uses: actions/github-script@v6 @@ -43,7 +39,6 @@ jobs: repo: context.repo.repo, body: 'Build successful! 🎉' }); - - name: Post failure comment if: ${{ failure() }} uses: actions/github-script@v6 diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml new file mode 100644 index 0000000..43e5e6a --- /dev/null +++ b/.github/workflows/version.yaml @@ -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! ❌' + }); \ No newline at end of file