/
update.sh
46 lines (36 loc) · 1.47 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <new_version_tag>"
exit 1
fi
# Extract new version tag from the first argument
new_version="$1"
current_version=$(grep -oP "VERSION\s*=\s*'([^']+)" src/SAGisXPlanung/__init__.py | awk -F"'" '{print $2}')
echo "Current application version: $current_version"
# List of files to update
files=("setup.py" "setup.cfg" "installer/setup.iss" "src/SAGisXPlanung/metadata.txt" "src/SAGisXPlanung/__init__.py")
# Loop through each file and perform version replacement
for file in "${files[@]}"; do
# Check if the file exists
if [ ! -f "$file" ]; then
echo "File not found: $file"
continue
fi
# Perform version replacement using sed
sed -i "s/\($current_version\)/$new_version/I" "$file"
echo "Version in $file updated from $current_version to $new_version"
done
# Rename sql file for database setup
# TODO: not only rename the file, but also generate new changes from alembic upgrade head
old_sql_file="src/SAGisXPlanung/database/create_v$current_version.sql"
new_sql_file="src/SAGisXPlanung/database/create_v$new_version.sql"
if [ -f "$old_sql_file" ]; then
git mv "$old_sql_file" "$new_sql_file"
echo "File $old_sql_file renamed to $new_sql_file"
else
echo "File $old_sql_file not found. No renaming performed."
echo "Check if database create script is present."
exit 1 # Exit with an error code
fi
echo "Version update complete."