merge: branch 'ih/versions-packit'

versioning: use everywhere the versioning scheme from the Git tags

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2332
This commit is contained in:
Íñigo Huguet 2025-12-19 14:52:53 +00:00
commit 8eea5a3d1a
5 changed files with 117 additions and 135 deletions

View file

@ -13,9 +13,7 @@
%global glib2_version %(pkg-config --modversion glib-2.0 2>/dev/null || echo bad) %global glib2_version %(pkg-config --modversion glib-2.0 2>/dev/null || echo bad)
%global epoch_version 1 %global epoch_version 1
%global real_version __VERSION__ %global base_version __VERSION__
%global git_tag_version __GIT_TAG_VERSION__
%global rpm_version %{real_version}
%global release_version __RELEASE_VERSION__ %global release_version __RELEASE_VERSION__
%global snapshot __SNAPSHOT__ %global snapshot __SNAPSHOT__
%global git_sha __COMMIT__ %global git_sha __COMMIT__
@ -29,7 +27,7 @@
%global obsoletes_ifcfg_rh 1:1.36.2 %global obsoletes_ifcfg_rh 1:1.36.2
%global nmlibdir %{_prefix}/lib/%{name} %global nmlibdir %{_prefix}/lib/%{name}
%global nmplugindir %{_libdir}/%{name}/%{version}-%{release} %global nmplugindir %{_libdir}/%{name}/%{version_no_tilde}-%{release}
%global _hardened_build 1 %global _hardened_build 1
@ -42,8 +40,6 @@
%global snap %{?snapshot_dot}%{?git_sha_dot} %global snap %{?snapshot_dot}%{?git_sha_dot}
%global real_version_major %(printf '%s' '%{real_version}' | sed -n 's/^\\([1-9][0-9]*\\.[0-9][0-9]*\\)\\.[0-9][0-9]*$/\\1/p')
%global systemd_units NetworkManager.service NetworkManager-wait-online.service NetworkManager-dispatcher.service nm-priv-helper.service %global systemd_units NetworkManager.service NetworkManager-wait-online.service NetworkManager-dispatcher.service nm-priv-helper.service
%global systemd_units_cloud_setup nm-cloud-setup.service nm-cloud-setup.timer %global systemd_units_cloud_setup nm-cloud-setup.service nm-cloud-setup.timer
@ -169,13 +165,13 @@
Name: NetworkManager Name: NetworkManager
Summary: Network connection manager and user applications Summary: Network connection manager and user applications
Epoch: %{epoch_version} Epoch: %{epoch_version}
Version: %{rpm_version} Version: %{base_version}
Release: %{release_version}%{?snap}%{?dist} Release: %{release_version}%{?snap}%{?dist}
Group: System Environment/Base Group: System Environment/Base
License: GPL-2.0-or-later AND LGPL-2.1-or-later License: GPL-2.0-or-later AND LGPL-2.1-or-later
URL: https://networkmanager.dev/ URL: https://networkmanager.dev/
#Source: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/releases/%{git_tag_version}/downloads/%{name}-%{real_version}.tar.xz #Source: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/releases/%{version_no_tilde}/downloads/%{name}-%{version_no_tilde}.tar.xz
Source: __SOURCE1__ Source: __SOURCE1__
Source1: NetworkManager.conf Source1: NetworkManager.conf
Source2: 00-server.conf Source2: 00-server.conf
@ -580,7 +576,7 @@ Preferably use nmcli instead.
%prep %prep
%autosetup -p1 -n NetworkManager-%{real_version} %autosetup -p1 -n NetworkManager-%{version_no_tilde}
%build %build
@ -760,8 +756,8 @@ rm -f %{buildroot}%{_unitdir}/NetworkManager-wait-online-initrd.service
find %{buildroot}%{_datadir}/gtk-doc -exec touch --reference meson.build '{}' \+ find %{buildroot}%{_datadir}/gtk-doc -exec touch --reference meson.build '{}' \+
%if 0%{?__debug_package} && ! 0%{?flatpak} %if 0%{?__debug_package} && ! 0%{?flatpak}
mkdir -p %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version} mkdir -p %{buildroot}%{_prefix}/src/debug/NetworkManager-%{version_no_tilde}
cp valgrind.suppressions %{buildroot}%{_prefix}/src/debug/NetworkManager-%{real_version} cp valgrind.suppressions %{buildroot}%{_prefix}/src/debug/NetworkManager-%{version_no_tilde}
%endif %endif
%if %{with ifcfg_rh} %if %{with ifcfg_rh}

View file

@ -12,7 +12,6 @@ set -o pipefail
# RELEASE_VERSION= # RELEASE_VERSION=
# SNAPSHOT= # SNAPSHOT=
# VERSION= # VERSION=
# GIT_TAG_VERSION=
# COMMIT_FULL= # COMMIT_FULL=
# COMMIT= # COMMIT=
# USERNAME= # USERNAME=
@ -113,7 +112,6 @@ UUID=`uuidgen`
RELEASE_VERSION="${RELEASE_VERSION:-$(git rev-list HEAD | wc -l)}" RELEASE_VERSION="${RELEASE_VERSION:-$(git rev-list HEAD | wc -l)}"
SNAPSHOT="${SNAPSHOT:-%{nil\}}" SNAPSHOT="${SNAPSHOT:-%{nil\}}"
VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}" VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
GIT_TAG_VERSION="${GIT_TAG_VERSION:-$VERSION}"
COMMIT_FULL="${COMMIT_FULL:-$(git rev-parse --verify HEAD || die "Error reading HEAD revision")}" COMMIT_FULL="${COMMIT_FULL:-$(git rev-parse --verify HEAD || die "Error reading HEAD revision")}"
COMMIT="${COMMIT:-$(printf '%s' "$COMMIT_FULL" | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}" COMMIT="${COMMIT:-$(printf '%s' "$COMMIT_FULL" | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}"
BCOND_DEFAULT_DEBUG="${BCOND_DEFAULT_DEBUG:-0}" BCOND_DEFAULT_DEBUG="${BCOND_DEFAULT_DEBUG:-0}"
@ -157,7 +155,6 @@ if [[ "$SOURCE_FROM_GIT" == "1" ]]; then
fi fi
LOG "VERSION=$VERSION" LOG "VERSION=$VERSION"
LOG "GIT_TAG_VERSION=$GIT_TAG_VERSION"
LOG "RELEASE_VERSION=$RELEASE_VERSION" LOG "RELEASE_VERSION=$RELEASE_VERSION"
LOG "SNAPSHOT=$SNAPSHOT" LOG "SNAPSHOT=$SNAPSHOT"
LOG "COMMIT_FULL=$COMMIT_FULL" LOG "COMMIT_FULL=$COMMIT_FULL"
@ -209,8 +206,7 @@ cp "$SOURCE_README_IFCFG_MIGRATED" "$TEMP/SOURCES/readme-ifcfg-rh-migrated.txt"
write_changelog write_changelog
sed -e "s/__VERSION__/$VERSION/g" \ sed -e "s/__VERSION__/${VERSION/-/\~}/g" \
-e "s/__GIT_TAG_VERSION__/$GIT_TAG_VERSION/g" \
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \ -e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \ -e "s/__SNAPSHOT__/$SNAPSHOT/g" \
-e "s/__COMMIT__/$COMMIT/g" \ -e "s/__COMMIT__/$COMMIT/g" \

View file

@ -102,14 +102,8 @@ do_command() {
SCRIPTDIR="$(dirname "$(readlink -f "$0")")" SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
GITDIR="$(cd "$SCRIPTDIR" && git rev-parse --show-toplevel || die "Could not get GITDIR")" GITDIR="$(cd "$SCRIPTDIR" && git rev-parse --show-toplevel || die "Could not get GITDIR")"
parse_version() { get_version() {
local VERSION=$(grep -E -m1 '^\s+version:' "$GITDIR/meson.build" \ grep -E -m1 '^\s+version:' "$GITDIR/meson.build" | cut -d"'" -f2
| cut -d"'" -f2 \
| sed 's/\./ /g')
re='^(0|[1-9][0-9]*) (0|[1-9][0-9]*) (0|[1-9][0-9]*)$'
[[ "$VERSION" =~ $re ]] || return 1
echo "$VERSION"
} }
number_is_even() { number_is_even() {
@ -155,7 +149,7 @@ check_gitlab_pipeline() {
set_version_number() { set_version_number() {
sed -i \ sed -i \
-e '1,20 s/^\( *version: *'\''\)[0-9]\+\.[0-9]\+\.[0-9]\+\('\'',\)$/\1'"$1.$2.$3"'\2/' \ -E "1,20 s/^( *version: *')[^']+(',) *\$/\1$1\2/" \
meson.build meson.build
} }
@ -259,12 +253,12 @@ done
[ -n "$RELEASE_MODE" ] || die_usage "specify the desired release mode" [ -n "$RELEASE_MODE" ] || die_usage "specify the desired release mode"
VERSION_ARR=( $(parse_version) ) || die "cannot detect NetworkManager version" VERSION_STR="$(get_version)"
VERSION_STR="$(IFS=.; echo "${VERSION_ARR[*]}")" VERSION_ARR=( $(echo "$VERSION_STR" | sed 's/[\.\-]/ /g') )
echo "Current version before release: $VERSION_STR (do \"$RELEASE_MODE\" release)" echo "Current version before release: $VERSION_STR (do \"$RELEASE_MODE\" release)"
grep -q "version: '${VERSION_ARR[0]}.${VERSION_ARR[1]}.${VERSION_ARR[2]}'," ./meson.build || die "meson.build does not have expected version" grep -q "version: '$VERSION_STR'," ./meson.build || die "meson.build does not have expected version"
TMP="$(git status --porcelain)" || die "git status failed" TMP="$(git status --porcelain)" || die "git status failed"
test -z "$TMP" || die "git working directory is not clean (git status --porcelain)" test -z "$TMP" || die "git working directory is not clean (git status --porcelain)"
@ -293,37 +287,42 @@ else
fi fi
RC_VERSION= RC_VERSION=
if [[ ${VERSION_ARR[2]} =~ ^rc ]]; then
RC_VERSION=${VERSION_ARR[2]#rc}
VERSION_ARR[2]=0
fi
RELEASE_BRANCH= RELEASE_BRANCH=
case "$RELEASE_MODE" in case "$RELEASE_MODE" in
minor) minor)
number_is_even "${VERSION_ARR[1]}" || die "cannot do minor release on top of version $VERSION_STR" number_is_even "${VERSION_ARR[1]}" || die "cannot do minor release on top of version $VERSION_STR"
[ "$RC_VERSION" = "" ] || die "cannot do a minor release on top of an RC version"
[ "$CUR_BRANCH" != main ] || die "cannot do a minor release on main" [ "$CUR_BRANCH" != main ] || die "cannot do a minor release on main"
;; ;;
devel) devel)
number_is_odd "${VERSION_ARR[1]}" || die "cannot do devel release on top of version $VERSION_STR" number_is_odd "${VERSION_ARR[1]}" || die "cannot do devel release on top of version $VERSION_STR"
[ "$((${VERSION_ARR[2]} + 1))" -lt 90 ] || die "devel release must have a micro version smaller than 90 but current version is $VERSION_STR" [ "$RC_VERSION" = "" ] || die "cannot do a devel release on top of an RC version"
[ "$CUR_BRANCH" == main ] || die "devel release can only be on main" [ "$CUR_BRANCH" == main ] || die "devel release can only be on main"
;; ;;
rc) rc)
number_is_odd "${VERSION_ARR[1]}" || die "cannot do rc release on top of version $VERSION_STR" number_is_odd "${VERSION_ARR[1]}" || die "cannot do rc release on top of version $VERSION_STR"
[ "${VERSION_ARR[2]}" -ge 90 ] || die "rc release must have a micro version larger than ${VERSION_ARR[0]}.90 but current version is $VERSION_STR" [ "$RC_VERSION" != "" ] || die "rc release must be done on top of an RC version"
RC_VERSION="$((${VERSION_ARR[2]} - 88))"
[ "$CUR_BRANCH" == "nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))" ] || die "devel release can only be on \"nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))\" branch" [ "$CUR_BRANCH" == "nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))" ] || die "devel release can only be on \"nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))\" branch"
;; ;;
rc1) rc1)
number_is_odd "${VERSION_ARR[1]}" || die "cannot do rc release on top of version $VERSION_STR" number_is_odd "${VERSION_ARR[1]}" || die "cannot do rc release on top of version $VERSION_STR"
[ "${VERSION_ARR[2]}" -lt 90 ] || die "rc release must have a micro version smaller than ${VERSION_ARR[0]}.${VERSION_ARR[1]}.90 but current version is $VERSION_STR" [ "$RC_VERSION" = "" ] || die "rc1 release cannot be done on top of an RC version"
[ "$CUR_BRANCH" == main ] || die "rc1 release can only be on main" [ "$CUR_BRANCH" == main ] || die "rc1 release can only be on main"
RELEASE_BRANCH="nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))" RELEASE_BRANCH="nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))"
;; ;;
major) major)
number_is_odd "${VERSION_ARR[1]}" || die "cannot do major release on top of version $VERSION_STR" number_is_odd "${VERSION_ARR[1]}" || die "cannot do major release on top of version $VERSION_STR"
[ "${VERSION_ARR[2]}" -ge 90 ] || die "parent version for major release must have a micro version larger than ${VERSION_ARR[0]}.90 but current version is $VERSION_STR" [ "$RC_VERSION" != "" ] || die "major release must be done on top of an RC version"
[ "$CUR_BRANCH" == "nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))" ] || die "major release can only be on \"nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))\" branch" [ "$CUR_BRANCH" == "nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))" ] || die "major release can only be on \"nm-${VERSION_ARR[0]}-$((${VERSION_ARR[1]} + 1))\" branch"
;; ;;
major-post) major-post)
number_is_odd "${VERSION_ARR[1]}" || die "cannot do major-post release on top of version $VERSION_STR" number_is_odd "${VERSION_ARR[1]}" || die "cannot do major-post release on top of version $VERSION_STR"
[ "$((${VERSION_ARR[2]} + 1))" -lt 90 ] || die "major-post release must have a micro version smaller than 90 but current version is $VERSION_STR" [ "$RC_VERSION" = "" ] || die "major-post release cannot be done on top of an RC version"
[ "$CUR_BRANCH" == main ] || die "major-post release can only be on main" [ "$CUR_BRANCH" == main ] || die "major-post release can only be on main"
;; ;;
*) *)
@ -418,8 +417,8 @@ if [ $CHECK_GITLAB = 1 ]; then
fi fi
fi fi
BRANCHES=() PUSH_REFS=()
BUILD_TAG= BUILD_VERSION=
CLEANUP_CHECKOUT_BRANCH="$CUR_BRANCH" CLEANUP_CHECKOUT_BRANCH="$CUR_BRANCH"
@ -428,61 +427,21 @@ CLEANUP_REFS+=("refs/heads/$TMP_BRANCH")
case "$RELEASE_MODE" in case "$RELEASE_MODE" in
minor) minor)
set_version_number "${VERSION_ARR[0]}" "${VERSION_ARR[1]}" $(("${VERSION_ARR[2]}" + 1)) BUILD_VERSION="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))"
git commit -m "release: bump version to ${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))" -a || die "failed to commit release"
b="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))"
git tag -s -a -m "Tag $b" "$b" HEAD || die "failed to tag release"
BRANCHES+=("$b")
CLEANUP_REFS+=("refs/tags/$b")
BUILD_TAG="$b"
TAR_VERSION="$b"
;; ;;
devel) devel)
set_version_number "${VERSION_ARR[0]}" "${VERSION_ARR[1]}" $(("${VERSION_ARR[2]}" + 1)) BUILD_VERSION="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))"
git commit -m "release: bump version to ${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1)) (development)" -a || die "failed to commit devel version bump" BUILD_VERSION_DESCR="$BUILD_VERSION (development)"
BUILD_VERSION="${BUILD_VERSION}-dev"
b="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))"
git tag -s -a -m "Tag $b (development)" "$b-dev" HEAD || die "failed to tag release"
BRANCHES+=("$b-dev")
CLEANUP_REFS+=("refs/tags/$b-dev")
BUILD_TAG="$b-dev"
TAR_VERSION="$b"
;; ;;
rc) rc)
b="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))" BUILD_VERSION="${VERSION_ARR[0]}.$(("${VERSION_ARR[1]}" + 1))-rc$(( $RC_VERSION + 1 ))"
t="${VERSION_ARR[0]}.$(("${VERSION_ARR[1]}" + 1))-rc$RC_VERSION"
set_version_number "${VERSION_ARR[0]}" "${VERSION_ARR[1]}" $(("${VERSION_ARR[2]}" + 1))
git commit -m "release: bump version to $b ($t) (development)" -a || die "failed to commit rc version bump"
git tag -s -a -m "Tag $b ($t) (development)" "$t" HEAD || die "failed to tag release"
BRANCHES+=("$t")
CLEANUP_REFS+=("refs/tags/$t")
BUILD_TAG="$t"
TAR_VERSION="$b"
;; ;;
rc1) rc1)
set_version_number "${VERSION_ARR[0]}" "${VERSION_ARR[1]}" 90 BUILD_VERSION="${VERSION_ARR[0]}.$(("${VERSION_ARR[1]}" + 1))-rc1"
b="${VERSION_ARR[0]}.${VERSION_ARR[1]}.90"
t="${VERSION_ARR[0]}.$(("${VERSION_ARR[1]}" + 1))-rc1"
git commit -m "release: bump version to $b ($t)" -a || die "failed to commit rc1 version bump"
git tag -s -a -m "Tag $b ($t) (development)" "$t" HEAD || die "failed to tag release $t"
BRANCHES+=("$t")
CLEANUP_REFS+=("refs/tags/$t")
BUILD_TAG="$t"
TAR_VERSION="$b"
;; ;;
major) major)
b="${VERSION_ARR[0]}.$((${VERSION_ARR[1]} + 1)).0" BUILD_VERSION="${VERSION_ARR[0]}.$((${VERSION_ARR[1]} + 1)).0"
set_version_number "${VERSION_ARR[0]}" "$((${VERSION_ARR[1]} + 1))" 0
git commit -m "release: bump version to $b" -a || die "failed to commit major version bump"
git tag -s -a -m "Tag $b" "$b" HEAD || die "failed to tag release"
BRANCHES+=("$b")
CLEANUP_REFS+=("refs/tags/$b")
BUILD_TAG="$b"
TAR_VERSION="$b"
;; ;;
major-post) major-post)
# We create a merge commit with the content of current "main", with two # We create a merge commit with the content of current "main", with two
@ -494,62 +453,60 @@ case "$RELEASE_MODE" in
git merge -Xours --commit -m tmp main || die "merge1" git merge -Xours --commit -m tmp main || die "merge1"
git rm --cached -r . || die "merge2" git rm --cached -r . || die "merge2"
git checkout main -- . || die "merge3" git checkout main -- . || die "merge3"
b="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$((${VERSION_ARR[2]} + 1))"
git commit --amend -m tmp -a || die "failed to commit major version bump" git commit --amend -m tmp -a || die "failed to commit major version bump"
test x = "x$(git diff main HEAD)" || die "there is a diff after merge!" test x = "x$(git diff main HEAD)" || die "there is a diff after merge!"
set_version_number "${VERSION_ARR[0]}" "${VERSION_ARR[1]}" "$((${VERSION_ARR[2]} + 1))" BUILD_VERSION="${VERSION_ARR[0]}.${VERSION_ARR[1]}.$(("${VERSION_ARR[2]}" + 1))"
git commit --amend -m "release: bump version to $b (development)" -a || die "failed to commit major version bump" BUILD_VERSION_DESCR="$BUILD_VERSION (development)"
git tag -s -a -m "Tag $b (development)" "$b-dev" HEAD || die "failed to tag release" BUILD_VERSION="${BUILD_VERSION}-dev"
BRANCHES+=("$b-dev")
CLEANUP_REFS+=("refs/tags/$b-dev")
BUILD_TAG="$b-dev"
TAR_VERSION="$b"
;; ;;
*) *)
die "Release mode $RELEASE_MODE not yet implemented" die "Release mode $RELEASE_MODE not yet implemented"
;; ;;
esac esac
build_tag() { build_version() {
local BUILD_TAG="$1" local BUILD_VERSION="$1"
local TAR_FILE="NetworkManager-$2.tar.xz" local BUILD_VERSION_DESCR="$2"
local TAR_FILE="NetworkManager-$BUILD_VERSION.tar.xz"
local SUM_FILE="$TAR_FILE.sha256sum" local SUM_FILE="$TAR_FILE.sha256sum"
git checkout "$BUILD_TAG" || die "failed to checkout $BUILD_TAG" set_version_number "$BUILD_VERSION"
git commit -m "release: bump version to $BUILD_VERSION_DESCR" -a || die "failed to commit release"
git tag -s -a -m "Release $BUILD_VERSION_DESCR" "$BUILD_VERSION" HEAD || die "failed to tag release"
PUSH_REFS+=("$BUILD_VERSION")
CLEANUP_REFS+=("refs/tags/$BUILD_VERSION")
git checkout "$BUILD_VERSION" || die "failed to checkout $BUILD_VERSION"
./contrib/fedora/rpm/build_clean.sh -r || die "build release failed" ./contrib/fedora/rpm/build_clean.sh -r || die "build release failed"
cp "./build/meson-dist/$TAR_FILE" /tmp/ || die "failed to copy $TAR_FILE to /tmp" cp "./build/meson-dist/$TAR_FILE" /tmp/ || die "failed to copy $TAR_FILE to /tmp"
cp "./build/meson-dist/$SUM_FILE" /tmp/ || die "failed to copy $SUM_FILE to /tmp" cp "./build/meson-dist/$SUM_FILE" /tmp/ || die "failed to copy $SUM_FILE to /tmp"
git clean -fdx git clean -fdx
RELEASE_VERSIONS+=("$BUILD_VERSION")
} }
RELEASE_TAR_VERSIONS=() RELEASE_VERSIONS=()
RELEASE_TAGS=() if [ -n "$BUILD_VERSION" ]; then
if [ -n "$BUILD_TAG" ]; then build_version "$BUILD_VERSION" "${BUILD_VERSION_DESCR:-$BUILD_VERSION}"
build_tag "$BUILD_TAG" "$TAR_VERSION"
RELEASE_TAR_VERSIONS+=("$TAR_VERSION")
RELEASE_TAGS+=("$BUILD_TAG")
fi fi
git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH"
BRANCHES+=( "$CUR_BRANCH" ) PUSH_REFS+=( "$CUR_BRANCH" )
if [ "$RELEASE_MODE" = rc1 ]; then if [ "$RELEASE_MODE" = rc1 ]; then
git branch "$RELEASE_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" git branch "$RELEASE_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH"
BRANCHES+=( "$RELEASE_BRANCH" ) PUSH_REFS+=( "$RELEASE_BRANCH" )
CLEANUP_REFS+=( "refs/heads/$RELEASE_BRANCH" ) CLEANUP_REFS+=( "refs/heads/$RELEASE_BRANCH" )
git checkout "$TMP_BRANCH" git checkout "$TMP_BRANCH"
b="${VERSION_ARR[0]}.$((${VERSION_ARR[1]} + 2)).0"
set_version_number "${VERSION_ARR[0]}" "$((${VERSION_ARR[1]} + 2))" 0 BUILD_VERSION="${VERSION_ARR[0]}.$((${VERSION_ARR[1]} + 2)).0"
git commit -m "release: bump version to $b (development)" -a || die "failed to commit devel version bump" BUILD_VERSION_DESCR="$BUILD_VERSION (development)"
git tag -s -a -m "Tag $b (development)" "$b-dev" HEAD || die "failed to tag release" BUILD_VERSION="${BUILD_VERSION}-dev"
BRANCHES+=("$b-dev") build_version "$BUILD_VERSION" "$BUILD_VERSION_DESCR"
CLEANUP_REFS+=("refs/tags/$b-dev")
BUILD_TAG="$b-dev"
TAR_VERSION="$b"
build_tag "$BUILD_TAG" "$TAR_VERSION"
RELEASE_TAR_VERSIONS+=("$TAR_VERSION")
RELEASE_TAGS+=("$BUILD_TAG")
git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH" git checkout -B "$CUR_BRANCH" "$TMP_BRANCH" || die "cannot checkout $CUR_BRANCH"
fi fi
@ -565,20 +522,19 @@ if [ -z "$GITLAB_USER_ID" ] || [ "$GITLAB_USER_ID" = "null" ]; then
die "failed to authenticate to gitlab.freedesktop.org with the private token" die "failed to authenticate to gitlab.freedesktop.org with the private token"
fi fi
do_command git push "$ORIGIN" "${BRANCHES[@]}" || die "failed to to push branches ${BRANCHES[@]} to $ORIGIN" do_command git push "$ORIGIN" "${PUSH_REFS[@]}" || die "failed to to push branches ${PUSH_REFS[@]} to $ORIGIN"
CREATE_RELEASE_FAIL=0 CREATE_RELEASE_FAIL=0
for I in "${!RELEASE_TAR_VERSIONS[@]}"; do for BUILD_VERSION in "${RELEASE_VERSIONS[@]}"; do
TAR_FILE="NetworkManager-${RELEASE_TAR_VERSIONS[$I]}.tar.xz" TAR_FILE="NetworkManager-$BUILD_VERSION.tar.xz"
SUM_FILE="$TAR_FILE.sha256sum" SUM_FILE="$TAR_FILE.sha256sum"
BUILD_TAG="${RELEASE_TAGS["$I"]}"
FAIL=0 FAIL=0
# upload tarball and checksum file as generic packages # upload tarball and checksum file as generic packages
for F in "$TAR_FILE" "$SUM_FILE"; do for F in "$TAR_FILE" "$SUM_FILE"; do
do_command curl --location --fail-with-body --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ do_command curl --location --fail-with-body --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--upload-file "/tmp/$F" \ --upload-file "/tmp/$F" \
"https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$F" \ "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_VERSION/$F" \
|| FAIL=1 || FAIL=1
if [[ $FAIL = 1 ]]; then if [[ $FAIL = 1 ]]; then
@ -595,25 +551,25 @@ for I in "${!RELEASE_TAR_VERSIONS[@]}"; do
--request POST "https://gitlab.freedesktop.org/api/v4/projects/411/releases" \ --request POST "https://gitlab.freedesktop.org/api/v4/projects/411/releases" \
--data "$(cat <<END --data "$(cat <<END
{ {
"name": "NetworkManager $BUILD_TAG", "name": "NetworkManager $BUILD_VERSION",
"tag_name": "$BUILD_TAG", "tag_name": "$BUILD_VERSION",
"assets": { "assets": {
"links": [ "links": [
{ {
"name": "NetworkManager $BUILD_TAG tarball with docs", "name": "NetworkManager $BUILD_VERSION tarball with docs",
"url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$TAR_FILE", "url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_VERSION/$TAR_FILE",
"direct_asset_path": "/$TAR_FILE", "direct_asset_path": "/$TAR_FILE",
"link_type":"package" "link_type":"package"
}, },
{ {
"name": "NetworkManager $BUILD_TAG tarball sha256sum", "name": "NetworkManager $BUILD_VERSION tarball sha256sum",
"url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_TAG/$SUM_FILE", "url": "https://gitlab.freedesktop.org/api/v4/projects/411/packages/generic/NetworkManager/$BUILD_VERSION/$SUM_FILE",
"direct_asset_path": "/$SUM_FILE", "direct_asset_path": "/$SUM_FILE",
"link_type":"package" "link_type":"package"
}, },
{ {
"name": "NEWS", "name": "NEWS",
"url": "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/$BUILD_TAG/NEWS?ref_type=tags", "url": "https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/$BUILD_VERSION/NEWS?ref_type=tags",
"direct_asset_path": "/NEWS", "direct_asset_path": "/NEWS",
"link_type":"other" "link_type":"other"
} }
@ -624,7 +580,7 @@ END
)" || FAIL=1 )" || FAIL=1
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
fail_msg "failed to create NetworkManager $BUILD_TAG release" fail_msg "failed to create NetworkManager $BUILD_VERSION release"
CREATE_RELEASE_FAIL=1 CREATE_RELEASE_FAIL=1
continue continue
fi fi

View file

@ -5,23 +5,47 @@ project(
# NOTE: When incrementing version also add corresponding # NOTE: When incrementing version also add corresponding
# NM_VERSION_x_y_z macros in # NM_VERSION_x_y_z macros in
# "src/libnm-core-public/nm-version-macros.h.in" # "src/libnm-core-public/nm-version-macros.h.in"
version: '1.57.1', version: '1.57.1-dev',
license: 'GPL2+', license: 'GPL2+',
default_options: [ default_options: [
'buildtype=debugoptimized', 'buildtype=debugoptimized',
'c_std=gnu11', 'c_std=gnu11',
'warning_level=2' # value "2" will add "-Wall" and "-Wextra" to the compiler flags '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_name = meson.project_name()
nm_version = meson.project_version() nm_version = meson.project_version()
version_array = nm_version.split('.')
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_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int() nm_minor_version = version_array[1].to_int()
nm_micro_version = version_array[2].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' nm_id_prefix = 'NM'

View file

@ -688,7 +688,17 @@ class Util:
micro = ver & 0xFF micro = ver & 0xFF
minor = (ver >> 8) & 0xFF minor = (ver >> 8) & 0xFF
major = ver >> 16 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)
############################################################################### ###############################################################################