meson: specify project version with the -dev and -rc suffixes

This will create the tarball with names NetworkManager-1.56-rc2.tar.xz
or NetworkManager-1.57.1-dev.tar.xz. This way they will match with the
name of the Git tag, making easier for users, and specially for tools
like Packit, to understand the versioning scheme.

The goal is to make that there is only one public versioning scheme, the
one with -rc and -dev suffixes. Version numbers with micro>=90 for RC
releases is kept only as an internal thing for the C headers. Users of
the API can still use it.
This commit is contained in:
Íñigo Huguet 2025-12-18 10:49:33 +01:00
parent a2d147366c
commit 030efdd763
2 changed files with 42 additions and 8 deletions

View file

@ -5,23 +5,47 @@ project(
# NOTE: When incrementing version also add corresponding
# NM_VERSION_x_y_z macros in
# "src/libnm-core-public/nm-version-macros.h.in"
version: '1.57.1',
version: '1.57.1-dev',
license: 'GPL2+',
default_options: [
'buildtype=debugoptimized',
'c_std=gnu11',
'warning_level=2' # value "2" will add "-Wall" and "-Wextra" to the compiler flags
],
meson_version: '>= 0.53.0',
meson_version: '>= 0.56.0',
)
nm_name = meson.project_name()
nm_version = meson.project_version()
version_array = nm_version.split('.')
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int()
nm_micro_version = version_array[2].to_int()
version_and_suffix = nm_version.split('-')
version_array = version_and_suffix[0].split('.')
if version_and_suffix.length() == 2
version_suffix = version_and_suffix[1]
else
assert(version_and_suffix.length() == 1)
version_suffix = ''
endif
if version_suffix == '' or version_suffix == 'dev'
assert(version_array.length() == 3)
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int()
nm_micro_version = version_array[2].to_int()
elif version_suffix.startswith('rc')
assert(version_array.length() == 2)
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int() - 1
nm_micro_version = version_suffix.substring(2).to_int() + 89
else
error('Invalid suffix: ' + version_suffix)
endif
if nm_minor_version % 2 == 1 and version_suffix == ''
error('Expected a "-dev" or "-rc" suffix')
elif nm_minor_version %2 == 0 and version_suffix != ''
error('Unexpected "' + version_suffix + '" suffix')
endif
nm_id_prefix = 'NM'

View file

@ -688,7 +688,17 @@ class Util:
micro = ver & 0xFF
minor = (ver >> 8) & 0xFF
major = ver >> 16
return "%s.%s.%s" % (major, minor, micro)
# Convert 1.57.1 -> 1.57.1-dev and 1.55.90 -> 1.56-rc1
if micro >= 90:
minor += 1
micro = "-rc" + str(micro - 89)
elif minor % 2 == 1:
micro = f".{micro}-dev"
else:
micro = f".{micro}"
return "%s.%s%s" % (major, minor, micro)
###############################################################################