Skip to content

Commit df3546f

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 df3546f

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ 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."
36+
)
3637
endif()
3738

3839
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: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ 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".
15-
# If git reports only a hash, the version will be set to "0.0.0.git.<hash>".
16-
# Otherwise we'll use 3-component version: major.minor.patch, just for CMake's
17-
# sake. A few extra variables will be set for Win dll metadata.
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, the
16+
# version will be set to "0.0.0". If git reports only a hash, the version will
17+
# be set to "0.0.0.git.<hash>". Otherwise we'll use 3-component version:
18+
# major.minor.patch, just for CMake's sake. A few extra variables will be set
19+
# for Win dll metadata.
1820
#
1921
# Important note: CMake does not support rc or git information. According to
2022
# semver rules, 1.5.1-rc1 should be less than 1.5.1, but it seems hard to
@@ -78,8 +80,22 @@ 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(
90+
STATUS "Using version from VERSION file: ${FILE_VERSION}")
91+
else()
92+
# VERSION file exists but is empty, use default ver: "0.0.0"
93+
return()
94+
endif()
95+
else()
96+
# no git and no VERSION file. Use default ver: "0.0.0"
97+
return()
98+
endif()
8399
endif()
84100

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

0 commit comments

Comments
 (0)