File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656 uses : actions/setup-python@v4
5757 with :
5858 python-version : " 3.11"
59+
60+ - name : Validate git versioning (Windows)
61+ if : runner.os == 'Windows'
62+ run : |
63+ $version = git describe --tags --long 2>$null
64+ if ($LASTEXITCODE -ne 0) {
65+ Write-Host "Error: No git tags found. Cannot determine version."
66+ Write-Host "Available tags:"
67+ git tag -l
68+ exit 1
69+ }
70+ Write-Host "Found version: $version"
71+
72+ - name : Validate git versioning (Unix)
73+ if : runner.os != 'Windows'
74+ run : |
75+ if ! version=$(git describe --tags --long 2>/dev/null); then
76+ echo "Error: No git tags found. Cannot determine version."
77+ echo "Available tags:"
78+ git tag -l
79+ exit 1
80+ fi
81+ echo "Found version: $version"
5982
6083 - name : Install build dependencies
6184 run : |
@@ -177,4 +200,4 @@ jobs:
177200 uses : pypa/gh-action-pypi-publish@release/v1
178201 with :
179202 packages-dir : dist
180- skip-existing : true
203+ skip-existing : false
Original file line number Diff line number Diff line change @@ -18,10 +18,26 @@ include_directories(${generated_files_dir})
1818
1919# Set the path for gitversion.h in the generated files directory
2020set (gitversion_h "${generated_files_dir} /gitversion.h" )
21+ # Run git describe without --always flag
22+ execute_process (
23+ COMMAND git describe --tags --long
24+ OUTPUT_VARIABLE version
25+ OUTPUT_STRIP_TRAILING_WHITESPACE
26+ RESULT_VARIABLE git_result
27+ ERROR_VARIABLE git_error
28+ )
2129
22- # Run git describe
23- execute_process (COMMAND git describe --long --always OUTPUT_VARIABLE version OUTPUT_STRIP_TRAILING_WHITESPACE )
24-
30+ # Check if git describe failed
31+ if (NOT git_result EQUAL 0)
32+ message (FATAL_ERROR "Failed to get version from git: ${git_error} \n "
33+ "Make sure you have tags in your repository.\n "
34+ "Create a tag with: git tag uuu_1.0.0" )
35+ endif ()
36+
37+ # Validate version format
38+ if (NOT version MATCHES "^uuu_[0-9]+\\ .[0-9]+\\ .[0-9]+(\\ -[0-9]+\\ -g[0-9a-f]+)?$" )
39+ message (FATAL_ERROR "Git version '${version} ' doesn't match expected format 'uuu_X.Y.Z' or 'uuu_X.Y.Z-N-gHASH'" )
40+ endif ()
2541# Add a custom command to generate definitions.h
2642if (WIN32 )
2743add_custom_command (
You can’t perform that action at this time.
0 commit comments