Files
TrustTunnel/scripts/ci/increment_version.sh
Andrey Meshkov d7273ea729 Pull request 94: Added auto-formatting and pre-commit hook
Squashed commit of the following:

commit 0dc9600ff3bd8573d805e4de4d85290b1052a222
Author: Andrey Meshkov <am@adguard.com>
Date:   Sun Dec 21 20:53:02 2025 +0300

    Rollback to the old changelog

commit fb56f619d5f703d712dbfdb95ab093a211dc0c58
Author: Andrey Meshkov <am@adguard.com>
Date:   Sun Dec 21 20:36:24 2025 +0300

    Improve the dev doc

commit afd44a5e2bebd51b07dcb587cf39ada925a42db9
Author: Andrey Meshkov <am@adguard.com>
Date:   Sun Dec 21 20:32:49 2025 +0300

    Added auto-formatting and pre-commit hook
2025-12-21 20:54:46 +03:00

66 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
set -e
MANIFEST_FILE=$1
increment_version() {
major=${1%%.*}
minor=$(echo ${1#*.} | sed -e "s/\.[0-9]*//")
revision=${1##*.}
echo ${major}.${minor}.$((revision+1))
}
VERSION=$(grep "version = " "$MANIFEST_FILE" | head -n 1 | sed -e 's/version = "\(.*\)"/\1/')
argument_version=$2
if [ -z "$argument_version" ]
then
NEW_VERSION=$(increment_version ${VERSION})
else
NEW_VERSION=$1
fi
if ! [[ "${NEW_VERSION}" =~ ^[0-9]\.[0-9]\.[0-9]*$ ]]
then
echo "New version is invalid: ${NEW_VERSION}"
exit 1
fi
echo "Last version was ${VERSION}"
echo "New version is ${NEW_VERSION}"
set -x
# Update toml
sed -i -e "s/^version = \"${VERSION}\"$/version = \"${NEW_VERSION}\"/" "$MANIFEST_FILE"
# Update changelog
sed -i -e "3{
/##/b
s/^/## ${NEW_VERSION}\n\n/
}" CHANGELOG.md
# Update Cargo.lock
python3 -c "
with open('Cargo.lock', 'r', encoding='UTF-8') as file:
content = file.read()
output = ''
is_in_trusttunnel_endpoint_section = False
for line in content.splitlines():
if line == 'name = \"trusttunnel_endpoint\"':
is_in_trusttunnel_endpoint_section = True
elif is_in_trusttunnel_endpoint_section:
is_in_trusttunnel_endpoint_section = line != '[[package]]'
if is_in_trusttunnel_endpoint_section and line == 'version = \"${VERSION}\"':
output += 'version = \"${NEW_VERSION}\"\n'
continue
output += line + '\n'
with open('Cargo.lock', 'w') as file:
file.write(output)
"