Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record git sha in packages during continuous builds #6

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 24 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading