Skip to content

Commit

Permalink
chore: Add version update script compatible with ci-tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 21, 2025
1 parent 199878f commit 66da842
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ec2993a28988bd147bf8f4f21a824c2fc5dbf7255e391b3ce517d337ebce5c1 /usr/local/bin/tox-bootstrapd
1b91d7fbd6da34b92d1ad85b289a00909e211203ffd8541ae5c0887dcc35f920 /usr/local/bin/tox-bootstrapd
38 changes: 19 additions & 19 deletions other/version-sync
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu

Expand All @@ -13,25 +13,25 @@ update() {
file="$SOURCE_DIR/$1"
expr="$2"

sed -e "$expr" "$file" > "$file.updated-version"
sed -e "$expr" "$file" >"$file.updated-version"
if diff "$file" "$file.updated-version"; then
rm "$file.updated-version"
else
# use cat > and rm instead of move to keep file permissions
cat "$file.updated-version" > "$file"
cat "$file.updated-version" >"$file"
rm "$file.updated-version"
fi
}

update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'
update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['"$VER"'])/'

update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'"$MAJOR"';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'"$MINOR"';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'"$PATCH"';/'

update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MAJOR "\).*"/\1'$MAJOR'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MINOR "\).*"/\1'$MINOR'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'$PATCH'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MAJOR "\).*"/\1'"$MAJOR"'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_MINOR "\).*"/\1'"$MINOR"'"/'
update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'"$PATCH"'"/'

#
# calculating the SO version
Expand Down Expand Up @@ -64,14 +64,14 @@ update 'CMakeLists.txt' 's/\(PROJECT_VERSION_PATCH "\).*"/\1'$PATCH'"/'
# this must be constant starting from the 1.0 release
LAST_SOMAJOR=2

if [ $MAJOR -eq 0 ]; then
if [ "$MAJOR" -eq 0 ]; then
SOMAJOR=$MINOR
SOMINOR=$PATCH

# update lastmajor above
update 'other/version-sync' 's/^\(LAST_SOMAJOR=\).*/\1'$SOMAJOR'/'
update 'other/version-sync' 's/^\(LAST_SOMAJOR=\).*/\1'"$SOMAJOR"'/'
else
SOMAJOR=$(expr $MAJOR + $LAST_SOMAJOR)
SOMAJOR=$(("$MAJOR" + "$LAST_SOMAJOR"))
SOMINOR=$MINOR
fi

Expand Down Expand Up @@ -115,16 +115,16 @@ fi
# <=> major.minor.patch
#

if [ $MAJOR -eq 0 ]; then
LIBTOOL_CURRENT=$(expr $SOMAJOR + $SOMINOR)
if [ "$MAJOR" -eq 0 ]; then
LIBTOOL_CURRENT=$(("$SOMAJOR" + "$SOMINOR"))
LIBTOOL_AGE=$SOMINOR
LIBTOOL_REVISION=0
else
LIBTOOL_CURRENT=$(expr $SOMAJOR + $SOMINOR)
LIBTOOL_CURRENT=$(("$SOMAJOR" + "$SOMINOR"))
LIBTOOL_AGE=$SOMINOR
LIBTOOL_REVISION=$PATCH
fi

update 'so.version' 's/^\(CURRENT=\).*/\1'$LIBTOOL_CURRENT'/'
update 'so.version' 's/^\(AGE=\).*/\1'$LIBTOOL_AGE'/'
update 'so.version' 's/^\(REVISION=\).*/\1'$LIBTOOL_REVISION'/'
update 'so.version' 's/^\(CURRENT=\).*/\1'"$LIBTOOL_CURRENT"'/'
update 'so.version' 's/^\(AGE=\).*/\1'"$LIBTOOL_AGE"'/'
update 'so.version' 's/^\(REVISION=\).*/\1'"$LIBTOOL_REVISION"'/'
15 changes: 15 additions & 0 deletions tools/update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -eux -o pipefail

VERSION=$1

GIT_ROOT=$(git rev-parse --show-toplevel)
cd "$GIT_ROOT"

# Strip suffixes (e.g. "-rc.1") from the version for the toxcore version sync.
VERSION="${VERSION%-*}"

IFS="." read -ra version_parts <<<"$VERSION"

other/version-sync "$GIT_ROOT" "${version_parts[0]}" "${version_parts[1]}" "${version_parts[2]}"

0 comments on commit 66da842

Please sign in to comment.