forked from RoEdAl/asterisk-chan-quectel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-release-tag.cmake
executable file
·44 lines (36 loc) · 1.14 KB
/
make-release-tag.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/cmake -P
CMAKE_PATH(GET CMAKE_SCRIPT_MODE_FILE PARENT_PATH SCRIPT_DIR)
EXECUTE_PROCESS(
COMMAND git status --porcelain
WORKING_DIRECTORY ${SCRIPT_DIR}
OUTPUT_VARIABLE GIT_STATUS
COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
IF(GIT_STATUS)
MESSAGE(FATAL_ERROR "There are uncommited changes")
ENDIF()
EXECUTE_PROCESS(
COMMAND git log -n 1 "--pretty=format:%H;%ct"
WORKING_DIRECTORY ${SCRIPT_DIR}
OUTPUT_VARIABLE GIT_LOG
COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
LIST(GET GIT_LOG 0 CHAN_SOURCE_VERSION)
LIST(GET GIT_LOG 1 CHAN_SOURCE_TS)
MESSAGE(DEBUG "Tagged commit: ${CHAN_SOURCE_VERSION}")
MESSAGE(DEBUG "Tag timestamp: ${CHAN_SOURCE_TS}")
EXECUTE_PROCESS(
COMMAND date --utc "--date=@${CHAN_SOURCE_TS}" "+v%Y.%m.%d"
WORKING_DIRECTORY ${SCRIPT_DIR}
OUTPUT_VARIABLE TAG_NAME
COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
MESSAGE(STATUS "Package version: ${TAG_NAME}")
EXECUTE_PROCESS(
COMMAND git tag -a -m "Package version" ${TAG_NAME} ${CHAN_SOURCE_VERSION}
WORKING_DIRECTORY ${SCRIPT_DIR}
COMMAND_ERROR_IS_FATAL ANY
)