From 1ed2cfdcc435b7fd5a7153943a4e005f4614d2d3 Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Fri, 12 Jun 2026 22:52:53 +0800 Subject: [PATCH] Update version scheme --- .githooks/pre-commit | 26 ++++++++++++++++++++++++++ CMakeLists.txt | 2 +- include/gmssl/version.h | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..84c9ba8f --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,26 @@ +#!/bin/sh +set -eu + +version_num="30200" +version_base="3.2.0-dev" +version_file="include/gmssl/version.h" +cmake_file="CMakeLists.txt" + +count=$(git rev-list --count HEAD) +next=$((count + 1)) +version="${version_base}.${next}" + +tmp="${version_file}.tmp" +sed \ + -e "s/^#define GMSSL_VERSION_NUM.*/#define GMSSL_VERSION_NUM ${version_num}/" \ + -e "s/^#define GMSSL_VERSION_STR.*/#define GMSSL_VERSION_STR \"GmSSL ${version}\"/" \ + "${version_file}" > "${tmp}" +mv "${tmp}" "${version_file}" + +tmp="${cmake_file}.tmp" +sed \ + -e "s/^set(CPACK_PACKAGE_VERSION .*/set(CPACK_PACKAGE_VERSION \"${version}\")/" \ + "${cmake_file}" > "${tmp}" +mv "${tmp}" "${cmake_file}" + +git add "${version_file}" "${cmake_file}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 11c1090e..f6469449 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -768,7 +768,7 @@ endif() # set(CPACK_PACKAGE_NAME "GmSSL") set(CPACK_PACKAGE_VENDOR "GmSSL develop team") -set(CPACK_PACKAGE_VERSION "3.1.3-Dev") +set(CPACK_PACKAGE_VERSION "3.2.0-dev.1014") set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/README.md) set(CPACK_NSIS_MODIFY_PATH ON) include(CPack) diff --git a/include/gmssl/version.h b/include/gmssl/version.h index 223a17b2..7b9b0d64 100644 --- a/include/gmssl/version.h +++ b/include/gmssl/version.h @@ -18,8 +18,8 @@ extern "C" { // Also update CPACK_PACKAGE_VERSION in CMakeLists.txt -#define GMSSL_VERSION_NUM 30103 -#define GMSSL_VERSION_STR "GmSSL 3.1.3 Dev" +#define GMSSL_VERSION_NUM 30200 +#define GMSSL_VERSION_STR "GmSSL 3.2.0-dev.1014" int gmssl_version_num(void); const char *gmssl_version_str(void);