Skip to content

Commit 7a18f88

Browse files
Add support for versioning in git archives
While releasing UMF we should update VERSION file, with the current version + "-dev".
1 parent cd038ff commit 7a18f88

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ static const umf_memory_provider_ops_t MY_PROVIDER_OPS = {
113113
- Requires `PTRACE_MODE_ATTACH_REALCREDS` permission
114114
- Uses `memfd_create()` or `memfd_secret()` for anonymous shared memory
115115
116-
When implementing new providers or pools, follow the existing patterns in `src/provider/provider_os_memory.c` and `src/pool/pool_scalable.c` as reference implementations.
116+
When implementing new providers or pools, follow the existing patterns in `src/provider/provider_os_memory.c` and `src/pool/pool_scalable.c` as reference implementations.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(UMF_CMAKE_VERSION VERSION_EQUAL "0.0.0")
3232
message(
3333
WARNING
3434
"UMF version is set to 0.0.0, which most likely is not expected! "
35-
"Please checkout the git tags to get a proper version.")
35+
"Please install git and checkout the git tags to get a proper version.")
3636
endif()
3737

3838
if(PROJECT_VERSION_PATCH GREATER 0)

RELEASE_STEPS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ Prepare changes for the release:
5050
- Once all changes are done, build locally (and/or verify changes on CI), including:
5151
- Verify if scanners/linters/checkers passed
5252
- Verify if version is set properly, especially in `.dll` and `.so` files
53+
- Create/update a VERSION file for GitHub ZIP downloads (users without git):
54+
- `echo "$VERSION-dev" > VERSION`
55+
- This ensures users downloading source ZIPs get correct version instead of "0.0.0"
5356
- Commit these changes and tag the release:
57+
- `git add VERSION`
5458
- `git commit -a -S -m "$VERSION release"`
5559
- `git tag -a -s -m "Version $VERSION" v$VERSION`
5660
- Verify if commit and tag are properly signed:

cmake/helpers.cmake

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ include(CheckCCompilerFlag)
1111
include(CheckCXXCompilerFlag)
1212

1313
# This function establishes version variables based on the git describe output.
14-
# If there's no git available in the system, the version will be set to "0.0.0".
14+
# If there's no git available in the system, it falls back to reading a VERSION
15+
# file from the project root. If neither git nor VERSION file is available,
16+
# the version will be set to "0.0.0".
1517
# If git reports only a hash, the version will be set to "0.0.0.git.<hash>".
1618
# Otherwise we'll use 3-component version: major.minor.patch, just for CMake's
1719
# sake. A few extra variables will be set for Win dll metadata.
@@ -78,8 +80,21 @@ function(set_version_variables)
7880
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
7981

8082
if(NOT GIT_VERSION)
81-
# no git or it reported no version. Use default ver: "0.0.0"
82-
return()
83+
# no git or it reported no version. Try fallback to VERSION file
84+
if(EXISTS "${UMF_CMAKE_SOURCE_DIR}/VERSION")
85+
file(READ "${UMF_CMAKE_SOURCE_DIR}/VERSION" FILE_VERSION)
86+
string(STRIP ${FILE_VERSION} FILE_VERSION)
87+
if(FILE_VERSION)
88+
set(GIT_VERSION "v${FILE_VERSION}")
89+
message(STATUS "Using version from VERSION file: ${FILE_VERSION}")
90+
else()
91+
# VERSION file exists but is empty, use default ver: "0.0.0"
92+
return()
93+
endif()
94+
else()
95+
# no git and no VERSION file. Use default ver: "0.0.0"
96+
return()
97+
endif()
8398
endif()
8499

85100
# v1.5.0 - we're exactly on a tag -> UMF ver: "1.5.0"

0 commit comments

Comments
 (0)