netcode 1.4.2 (#168) #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Check | |
| on: | |
| push: | |
| tags: [ 'v*' ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| version-check: | |
| name: tag matches project version | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check release version | |
| run: | | |
| cmake_version=$(sed -nE 's/^project\(netcode VERSION ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' CMakeLists.txt) | |
| header_full=$(sed -nE 's/^#define NETCODE_VERSION_FULL[[:space:]]+"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' netcode.h) | |
| major=$(sed -nE 's/^#define NETCODE_VERSION_MAJOR[[:space:]]+([0-9]+).*/\1/p' netcode.h) | |
| minor=$(sed -nE 's/^#define NETCODE_VERSION_MINOR[[:space:]]+([0-9]+).*/\1/p' netcode.h) | |
| patch=$(sed -nE 's/^#define NETCODE_VERSION_PATCH[[:space:]]+([0-9]+).*/\1/p' netcode.h) | |
| if [ -z "$cmake_version" ] || [ -z "$header_full" ] || [ -z "$major" ] || [ -z "$minor" ] || [ -z "$patch" ]; then | |
| echo "::error::Could not extract versions (CMakeLists.txt: '$cmake_version', NETCODE_VERSION_FULL: '$header_full', MAJOR/MINOR/PATCH: '$major.$minor.$patch')" | |
| exit 1 | |
| fi | |
| echo "CMakeLists.txt project version: $cmake_version" | |
| echo "netcode.h NETCODE_VERSION_FULL: $header_full" | |
| echo "netcode.h MAJOR.MINOR.PATCH: $major.$minor.$patch" | |
| if [ "$header_full" != "$major.$minor.$patch" ]; then | |
| echo "::error::NETCODE_VERSION_FULL ($header_full) does not match NETCODE_VERSION_MAJOR/MINOR/PATCH ($major.$minor.$patch) in netcode.h" | |
| exit 1 | |
| fi | |
| if [ "$cmake_version" != "$header_full" ]; then | |
| echo "::error::project(netcode VERSION $cmake_version) in CMakeLists.txt does not match NETCODE_VERSION_FULL ($header_full) in netcode.h" | |
| exit 1 | |
| fi | |
| case "$GITHUB_REF" in | |
| refs/tags/*) | |
| tag_version="${GITHUB_REF_NAME#v}" | |
| echo "Release tag version: $tag_version" | |
| if [ "$tag_version" != "$cmake_version" ]; then | |
| echo "::error::Tag $GITHUB_REF_NAME does not match version $cmake_version in CMakeLists.txt and netcode.h — bump both as part of the release." | |
| exit 1 | |
| fi | |
| ;; | |
| *) | |
| echo "Not a tag build, nothing more to check." | |
| ;; | |
| esac |