diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 0569119..b2b4e3a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -39,6 +39,7 @@ jobs: cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -DJSONSCHEMA_TESTS:BOOL=ON + -DJSONSCHEMA_CONTINUOUS:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON - run: cmake --build ./build --config Release --parallel 4 diff --git a/CMakeLists.txt b/CMakeLists.txt index a56bd53..926f5d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ include(cmake/CompilerOptions.cmake) # Options option(JSONSCHEMA_TESTS "Build the JSON Schema CLI tests" OFF) +option(JSONSCHEMA_CONTINUOUS "Perform a continuous JSON Schema CLI release" ON) find_package(JSONToolkit REQUIRED) add_subdirectory(src) @@ -24,9 +25,31 @@ if(JSONSCHEMA_TESTS) endif() # Packaging +find_program(GIT_BIN NAMES git) +if(GIT_BIN AND JSONSCHEMA_CONTINUOUS) + execute_process(COMMAND "${GIT_BIN}" rev-parse --git-dir + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE GIT_DIR) +endif() +if(GIT_BIN AND EXISTS "${GIT_DIR}") + execute_process( + COMMAND "${GIT_BIN}" rev-parse --short=8 HEAD + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + OUTPUT_VARIABLE PROJECT_GIT_SHA + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) +else() + set(PROJECT_GIT_SHA "unknown") +endif() + set(CPACK_GENERATOR ZIP) string(TOLOWER ${CMAKE_SYSTEM_NAME} LOWER_SYSTEM_NAME) set(PLATFORM_SUFFIX "${LOWER_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${PLATFORM_SUFFIX}") +if(JSONSCHEMA_CONTINUOUS) + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${PROJECT_GIT_SHA}-${PLATFORM_SUFFIX}") +else() + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${PLATFORM_SUFFIX}") +endif() set(CPACK_VERBATIM_VARIABLES YES) include(CPack) diff --git a/Makefile b/Makefile index 020860f..36495fe 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ configure: .always -DCMAKE_BUILD_TYPE:STRING=$(PRESET) \ -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \ -DJSONSCHEMA_TESTS:BOOL=ON \ + -DJSONSCHEMA_CONTINUOUS:BOOL=ON \ -DBUILD_SHARED_LIBS:BOOL=$(SHARED) compile: .always