From 3a054c1ffc34af8697d9d74061be5d3203958d40 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 14 Aug 2023 00:30:20 -0600 Subject: [PATCH] build: fix build labels on GitHub Actions --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfeaece7..d7c1fbdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,17 @@ execute_process( OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE ) +message(STATUS "git describe returned \"${GIT_DESCRIBE}\"") + +# git describe fails on GitHub Actions +if(NOT GIT_DESCRIBE) + # See: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables + if(NOT ("$ENV{GITHUB_REF_NAME}" STREQUAL "")) + set(GIT_DESCRIBE "$ENV{GITHUB_REF_NAME}") + + message(STATUS "using version label \"${GIT_DESCRIBE}\" from GITHUB_REF_NAME") + endif() +endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") add_compile_options(/EHsc)