Skip to content

Commit 7eacfa0

Browse files
danbevggerganov
authored andcommitted
ggml : introduce semantic versioning (ggml/1336)
* ggml : introduce semantic versioning This commit introduces semantic versioning for the GGML library. The motivation for this is that the current versioning, using build numbers, makes it difficult to track changes and releases for projects that use ggml. The release steps are the following: 1. Sync the changes from llama.cpp using sync-llama-am.sh and after the PR has been approved and merged move to step 2. 2. Run scripts/release.sh and specify the type of release, major, minor, or patch. This script will handle incrementing the version (major|minor|patch), create a new commit with the version change, create a tag for the version, and prepare for the next development iteration. 3. Inspect the commits/tag and push to master. This will trigger the github release workflow which is triggered for new tags which will then publish a new release on github. Example usage: ```console $ ./scripts/release.sh major --dry-run [dry-run] - No changes will be made Step 1: Reading current version... Current version: 0.9.0-dev New release version: 1.0.0 Step 2: Updating version in ggml/CMakeLists.txt... [dry-run] Would update GGML_VERSION_MAJOR to 1 [dry-run] Would update GGML_VERSION_MINOR to 0 [dry-run] Would update GGML_VERSION_PATCH to 0 [dry-run] Would remove -dev suffix Step 3: Committing version bump... [dry-run] Would commit: 'ggml : bump version to 1.0.0' Step 4: Creating git tag... [dry-run] Would create tag: v1.0.0 with message 'Release version 1.0.0' Step 5: Preparing for next development cycle... [dry-run] Would update GGML_VERSION_MINOR to 1 [dry-run] Would add -dev suffix back Step 6: Committing development version... [dry-run] Would commit: 'ggml : prepare for development of 1.1.0-dev' [dry-run] Summary (no changes were made): • Would have released version: 1.0.0 • Would have created tag: v1.0.0 • Would have set next development version: 1.1.0-dev ``` Refs: ggml-org/ggml#1333 * ggml: create branch for release candidate and check master * ggml : sign the git tag
1 parent 590fadb commit 7eacfa0

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

ggml/CMakeLists.txt

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
22
project("ggml" C CXX ASM)
3+
4+
### GGML Version
5+
set(GGML_VERSION_MAJOR 0)
6+
set(GGML_VERSION_MINOR 9)
7+
set(GGML_VERSION_PATCH 0)
8+
set(GGML_VERSION_DEV "-dev") # "-dev" for development, "" for releases
9+
set(GGML_VERSION_BASE "${GGML_VERSION_MAJOR}.${GGML_VERSION_MINOR}.${GGML_VERSION_PATCH}")
10+
11+
find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
12+
if(GIT_EXE)
13+
# Get current git commit hash
14+
execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD
15+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
16+
OUTPUT_VARIABLE GGML_BUILD_COMMIT
17+
OUTPUT_STRIP_TRAILING_WHITESPACE
18+
ERROR_QUIET
19+
)
20+
21+
# Check if the working directory is dirty (i.e., has uncommitted changes)
22+
execute_process(COMMAND ${GIT_EXE} diff-index --quiet HEAD -- .
23+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
24+
RESULT_VARIABLE GGML_GIT_DIRTY
25+
ERROR_QUIET
26+
)
27+
endif()
28+
29+
# Build the version string with optional -dev suffix and dirty flag
30+
set(GGML_VERSION "${GGML_VERSION_BASE}${GGML_VERSION_DEV}")
31+
if(GGML_GIT_DIRTY AND NOT GGML_GIT_DIRTY EQUAL 0)
32+
set(GGML_VERSION "${GGML_VERSION}-dirty")
33+
endif()
34+
35+
if(NOT GGML_BUILD_COMMIT)
36+
set(GGML_BUILD_COMMIT "unknown")
37+
endif()
38+
339
include(CheckIncludeFileCXX)
440

541
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -300,26 +336,6 @@ endif()
300336
# Create CMake package
301337
#
302338

303-
# Generate version info based on git commit.
304-
305-
if(NOT DEFINED GGML_BUILD_NUMBER)
306-
find_program(GIT_EXE NAMES git git.exe REQUIRED NO_CMAKE_FIND_ROOT_PATH)
307-
execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD
308-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
309-
OUTPUT_VARIABLE GGML_BUILD_NUMBER
310-
OUTPUT_STRIP_TRAILING_WHITESPACE
311-
)
312-
313-
if(GGML_BUILD_NUMBER EQUAL 1)
314-
message(WARNING "GGML build version fixed at 1 likely due to a shallow clone.")
315-
endif()
316-
317-
execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD
318-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
319-
OUTPUT_VARIABLE GGML_BUILD_COMMIT
320-
OUTPUT_STRIP_TRAILING_WHITESPACE
321-
)
322-
endif()
323339

324340

325341
# Capture variables prefixed with GGML_.
@@ -348,7 +364,7 @@ set(GGML_VARIABLES_EXPANDED ${variable_set_statements})
348364

349365
# Create the CMake package and set install location.
350366

351-
set(GGML_INSTALL_VERSION 0.0.${GGML_BUILD_NUMBER})
367+
set(GGML_INSTALL_VERSION ${GGML_VERSION})
352368
set(GGML_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of header files")
353369
set(GGML_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
354370
set(GGML_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")

0 commit comments

Comments
 (0)