mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
Feat: add version-based packaging script
Add script/package.bat and script/package.cmake to package build/bin artifacts into a versioned zip under dist/. Version.txt now uses Major/Minor/Patch key-value format so the script can parse it, and dist/ is ignored.
This commit is contained in:
1 parent
55303b7dc9
commit
560215c0ae
4 files changed
+88
-1
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
build/
|
build/
|
||||||
.cache/
|
.cache/
|
||||||
*.log
|
*.log
|
||||||
|
dist/
|
||||||
+3
-1
@@ -1 +1,3 @@
|
|||||||
Version 4.1.1
|
Major=4
|
||||||
|
Minor=1
|
||||||
|
Patch=1
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set "ROOT_DIR=%~dp0"
|
||||||
|
|
||||||
|
cmake -P "%ROOT_DIR%package.cmake"
|
||||||
|
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo [ERROR] Packaging failed.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo [SUCCESS] Packaging completed.
|
||||||
|
|
||||||
|
pause
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
# Resolve project directory
|
||||||
|
get_filename_component(PROJECT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||||
|
|
||||||
|
set(VERSION_FILE "${PROJECT_DIR}/Version.txt")
|
||||||
|
set(BIN_DIR "${PROJECT_DIR}/build/bin")
|
||||||
|
set(OUTPUT_DIR "${PROJECT_DIR}/dist")
|
||||||
|
file(MAKE_DIRECTORY "${OUTPUT_DIR}")
|
||||||
|
|
||||||
|
# Read version file
|
||||||
|
if(NOT EXISTS "${VERSION_FILE}")
|
||||||
|
message(FATAL_ERROR "Version.txt not found: ${VERSION_FILE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(STRINGS "${VERSION_FILE}" VERSION_LINES)
|
||||||
|
|
||||||
|
foreach(LINE IN LISTS VERSION_LINES)
|
||||||
|
if(LINE MATCHES "^[ \t]*Major[ \t]*=[ \t]*([0-9]+)[ \t]*$")
|
||||||
|
set(VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||||
|
elseif(LINE MATCHES "^[ \t]*Minor[ \t]*=[ \t]*([0-9]+)[ \t]*$")
|
||||||
|
set(VERSION_MINOR "${CMAKE_MATCH_1}")
|
||||||
|
elseif(LINE MATCHES "^[ \t]*Patch[ \t]*=[ \t]*([0-9]+)[ \t]*$")
|
||||||
|
set(VERSION_PATCH "${CMAKE_MATCH_1}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT DEFINED VERSION_MAJOR OR
|
||||||
|
NOT DEFINED VERSION_MINOR OR
|
||||||
|
NOT DEFINED VERSION_PATCH)
|
||||||
|
message(FATAL_ERROR "Invalid Version.txt: Major, Minor and Patch are required")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Define package files
|
||||||
|
set(PACKAGE_FILES
|
||||||
|
injector.exe
|
||||||
|
libinject.dll
|
||||||
|
libloader.dll
|
||||||
|
libagent.dll
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(FILE_NAME IN LISTS PACKAGE_FILES)
|
||||||
|
if(NOT EXISTS "${BIN_DIR}/${FILE_NAME}")
|
||||||
|
message(FATAL_ERROR "Required file not found: ${BIN_DIR}/${FILE_NAME}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Create package
|
||||||
|
set(OUTPUT_FILE
|
||||||
|
"${OUTPUT_DIR}/JuiceAgent_v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}_x64.zip"
|
||||||
|
)
|
||||||
|
|
||||||
|
file(REMOVE "${OUTPUT_FILE}")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E tar
|
||||||
|
cf "${OUTPUT_FILE}"
|
||||||
|
--format=zip
|
||||||
|
${PACKAGE_FILES}
|
||||||
|
WORKING_DIRECTORY "${BIN_DIR}"
|
||||||
|
RESULT_VARIABLE TAR_RESULT
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT TAR_RESULT STREQUAL "0")
|
||||||
|
message(FATAL_ERROR "Failed to create ZIP package: ${TAR_RESULT}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Package created: ${OUTPUT_FILE}")
|
||||||
Reference in new issue
Block a user