-
Notifications
You must be signed in to change notification settings - Fork 10
/
set-versions
executable file
·73 lines (59 loc) · 1.72 KB
/
set-versions
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
70
71
72
73
#!/bin/bash
set -e
function perl_substitution () {
local new_version="$1"
cat <<EOF
s{
(\[org\.iplantc[^"]*) # capture the group and artifact IDs
"[^"]*" # ignore the version and surrounding quotes
}
{\1"${new_version}"}gxms
EOF
}
function project_substitution () {
local new_version="$1"
cat <<EOF
s{
(\(defproject[^"]*)
"[^"]*"
}
{\1"${new_version}"}gxms
EOF
}
if [ $# -eq 0 ]; then
echo "USAGE: ./set-versions.sh <version>"
exit 1
fi
echo "NOTE: This script requires the lein-set-version plugin for Leiningen."
echo "I don't know if you have it already, but if you need it go to: "
echo "https://github.com/pallet/lein-set-version"
for project in $(find . -name project.clj -exec dirname '{}' \;); do
pushd $project 2>&1 > /dev/null
cljproj=$(basename $project)
if [ "$cljproj" == "terrain" ]; then
echo ">>> $cljproj: Setting version to $1-SNAPSHOT"
perl -pi -e "$(project_substitution $1-SNAPSHOT)" project.clj
else
echo ">>> $cljproj: Setting version to $1"
perl -pi -e "$(project_substitution $1)" project.clj
fi
echo ">>> $cljproj: Setting versions of all iPlant deps to $1"
#sed -i '' "s/\(\[org\.iplantc[^\"]*\"\)[^\"]*\"/\1$1\"/g" project.clj
perl -pi -e "$(perl_substitution $1)" project.clj
echo " "
popd 2>&1 > /dev/null
done
for project in $(find . -name version -type f -exec dirname '{}' \;); do
pushd $project 2>&1 > /dev/null
proj=$(basename $project)
if [ "$proj" == "terrain" ]; then
echo ">>> $proj: Setting $project/version to $1-SNAPSHOT"
echo "$1-SNAPSHOT" > ./version
echo " "
else
echo ">>> $proj: Setting $project/version to $1"
echo "$1" > ./version
echo " "
fi
popd 2>&1 > /dev/null
done