-
Notifications
You must be signed in to change notification settings - Fork 3
/
update-version.sh
69 lines (61 loc) · 1.77 KB
/
update-version.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# usage: update-version.sh new-version
#
# this will update the source code to refer to the new version
# in both the plugin and the template
if test -d ../frege-lein-plugin
then
echo "Found plugin."
else
echo "error: This should be run in the frege-lein-plugin folder."
exit 1
fi
if test -d ../frege-lein-template
then
echo "Found template."
else
echo "error: frege-lein-template folder not found (should be next to plugin)."
exit 1
fi
if test "x$1" = "x"
then
echo "usage: update-version.sh new-version"
exit 1
fi
new_version="$1"
new_major=$new_version
new_minor=ignored
if test "x$new_major" != "x" -a "x$new_minor" != "x" -a "x$new_major" != "x$new_minor"
then
echo "Will update to ${new_major}-${new_minor} version."
else
echo "error: new-version does not appear to be x.y.z-sha."
exit 1
fi
old_version=`fgrep 'private fregec-version' src/leiningen/fregec.clj | sed 's;.*"\(.*\)".*;\1;'`
if test "x$old_version" = "x"
then
echo "error: Cannot find current Frege version (in src/leiningen/fregec.clj)."
exit 1
else
echo "Found current version: ${old_version}."
fi
old_major=`echo $old_version | sed 's;-.*;;'`
files=`find . ../frege-lein-template -type f -exec fgrep -l $old_version {} \;`
for f in $files
do
echo "Updating $f..."
cp $f $f.update_version
sed "s;$old_version;$new_version;g" < $f.update_version > $f
done
find . ../frege-lein-template -name '*.update_version' -delete
files=`find . ../frege-lein-template -type f -exec fgrep -l $old_major {} \;`
for f in $files
do
echo "Updating $f..."
cp $f $f.update_version
sed "s;$old_major;$new_major;g" < $f.update_version > $f
done
find . ../frege-lein-template -name '*.update_version' -delete
echo "You should now review and commit the changes."