-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate-version.sh
More file actions
executable file
·60 lines (48 loc) · 1.2 KB
/
Copy pathupdate-version.sh
File metadata and controls
executable file
·60 lines (48 loc) · 1.2 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /bin/bash
set -e
# Parse the CLI
show_usage () {
echo "Usage: $(basename $0) <old version tag> <new version tag>"
echo
echo "Update a Python version tag."
echo ""
}
while [ ! -z "$1" ]; do
case "$1" in
-h)
show_usage
exit 0
;;
-*)
echo "Invalid option: $1."
echo
show_usage
exit 1
;;
*)
break
esac
done
if [ "$#" -ne 2 ]; then
echo "Invalid number of arguments. Got $#, expected 2."
echo
show_usage
exit 1
fi
# Process the version tag
match_and_replace() {
local prefix="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
if [ ! -f "${prefix}/appimage/recipes/python$1.sh" ]; then
echo "Error: invalid version tag: $1. Aborting."
exit 1
fi
local files=".travis/script.sh README.md appimage/recipes/python$1.sh tests/test_plugin.py"
local file
for file in ${files}; do
echo "updating tag in ${file}"
sed -i -- "s/$1/$2/g" "${prefix}/${file}"
done
git mv "${prefix}/appimage/recipes/python$1.sh" \
"${prefix}/appimage/recipes/python$2.sh"
}
match_and_replace "$@"