-
-
Notifications
You must be signed in to change notification settings - Fork 206
52 lines (48 loc) · 2.34 KB
/
Copy pathrelease-check.yml
File metadata and controls
52 lines (48 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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