]> prime8.dev >> repos - ttyd.git/commitdiff
cmake: add static version back
authorShuanglei Tao <tsl0922@gmail.com>
Sat, 30 Mar 2024 02:58:37 +0000 (10:58 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sat, 30 Mar 2024 02:58:37 +0000 (10:58 +0800)
.github/workflows/release.yml
CMakeLists.txt

index 3dd3b2d58300dcee8ae6d1f9d7eeb2184845db66..d5d2b2521b46c23401c3ba99872786b289e27262 100644 (file)
@@ -12,6 +12,15 @@ jobs:
     runs-on: ubuntu-22.04
     steps:
       - uses: actions/checkout@v4
+      - name: Check version bump
+        run: |
+          TAG=$(git describe --tags --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8)
+          VERSION=$(grep project CMakeLists.txt| awk '{print $3}')
+          if [ "$TAG" != "$VERSION" ]; then
+            echo "=== Version in CMakeLists.txt and git tag does not match!"
+            echo "=== Git Tag: $TAG, Version: $VERSION"
+            exit 1
+          fi
       - uses: actions/download-artifact@v4
       - run: |
           mkdir build
index 0bf19bcae038879b31c1baae6f5ebbb4e8fa99d9..0e2a61f5dbb0773e8e7e33def72393fb02a08b3a 100644 (file)
@@ -2,15 +2,18 @@ cmake_minimum_required(VERSION 3.12.0)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 
-include(GetGitVersion)
+project(ttyd VERSION 1.7.6 LANGUAGES C)
+
+set(TTYD_VERSION "${PROJECT_VERSION}")
 
+include(GetGitVersion)
 get_git_version(GIT_VERSION SEM_VER)
 get_git_head(GIT_COMMIT)
-
-project(ttyd VERSION "${SEM_VER}" LANGUAGES C)
-
-if(NOT "{GIT_COMMIT}" STREQUAL "")
-    set(PROJECT_VERSION "${PROJECT_VERSION}-${GIT_COMMIT}")
+if("${SEM_VER}" VERSION_GREATER "${TTYD_VERSION}")
+    set(TTYD_VERSION "${SEM_VER}")
+endif()
+if(NOT "${GIT_COMMIT}" STREQUAL "")
+    set(TTYD_VERSION "${TTYD_VERSION}-${GIT_COMMIT}")
 endif()
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
@@ -81,7 +84,7 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES})
 target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRS})
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 target_compile_definitions(${PROJECT_NAME} PUBLIC
-    TTYD_VERSION="${PROJECT_VERSION}"
+    TTYD_VERSION="${TTYD_VERSION}"
     $<$<PLATFORM_ID:Windows>:_WIN32_WINNT=0xa00 WINVER=0xa00>
 )