meson: Start adding devel and rc suffixes to the project version

Let's make sure that versions generated by meson-vcs-tag.sh always
sort higher than official and stable releases. We achieve this by
immediately updating the meson version in meson.build after a new
release. To make sure this version always sorts lower than future
rcs, we suffix it with "~devel" which will sort lower than "~rcX".

The new release workflow is to update the version in meson.build
for each rc and the official release and to also update the version
number after a new release to the next development version.

The full version is exposed as PROJECT_VERSION_FULL and used where
it makes sense over PROJECT_VERSION.

We also switch to reading the version from a meson.version file in
the repo instead of hardcoding it in meson.build. This makes it
easier to access both inside and outside of the project.

The meson-vcs-tag.sh script is rewritten to query the version from
meson.version instead of passing it in via the command line. This
makes it easier to use outside of systemd since users don't have to
query the version themselves first.
This commit is contained in:
Daan De Meyer
2024-02-14 15:36:34 +01:00
parent c0561a05f5
commit ea2a57bee3
15 changed files with 52 additions and 37 deletions
+12 -6
View File
@@ -4,14 +4,15 @@
set -u
set -o pipefail
dir="${1:?}"
fallback="${2:?}"
version_tag="${3:-}"
dir="${1:-.}"
version_tag="${2:-}"
if [ -n "${version_tag}" ]; then
# If -Dversion_tag= was used, just use that without further changes.
echo "${version_tag}"
else
read -r project_version <"${dir}/meson.version"
# Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
# and that we don't get confused if a tarball is extracted in a higher-level
# git repository.
@@ -22,13 +23,18 @@ else
c=''
if [ -e "${dir}/.git" ]; then
c="$(git -C "$dir" describe --abbrev=7 --dirty=^ 2>/dev/null)"
if [ -z "$c" ]; then
if [ -n "$c" ]; then
# git describe uses the most recent tag. However, for development versions (e.g. v256~devel), the
# most recent tag will be v255 as there is no tag for development versions. To deal with this, we
# replace the tag with the project version instead.
c="${project_version}-${c#*-}"
else
# This call might still fail with permission issues
suffix="$(git -C "$dir" describe --always --abbrev=7 --dirty=^ 2>/dev/null)"
[ -n "$suffix" ] && c="${fallback}-${suffix}"
[ -n "$suffix" ] && c="${project_version}-${suffix}"
fi
fi
[ -z "$c" ] && c="${fallback}"
[ -z "$c" ] && c="${project_version}"
# Replace any hyphens with carets which are allowed in versions by pacman whereas hyphens are not. Git
# versions with carets will also sort higher than their non-git version counterpart both in pacman
# versioning and in version comparison spec versioning.