forked from jbosstm/narayana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-release.sh
executable file
·102 lines (87 loc) · 3.64 KB
/
pre-release.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
. pre-release-vars.sh
function fatal {
echo "Failed: $1"
exit 1
}
#Get the versions, stripping off any '-SNAPSHOT' suffix
CURRENT=$(echo ${1} | awk -F '-SNAPSHOT' '{ print $1 }')
NEXT=$(echo ${2} | awk -F '-SNAPSHOT' '{ print $1 }')
if [ "$NEXT" == "" ]; then
echo "usage: $0 <current version> <next version>"
exit 1
fi
#Now add '-SNAPSHOT' to next version
NEXT="${NEXT}-SNAPSHOT"
echo "This script will:"
echo "================="
echo "Tag $CURRENT"
echo "Update Narayana $BRANCH to $NEXT"
echo ""
echo "Are you sure you want to continue? (y/n)"
read PROCEED
if [ "$PROCEED" != "y" ]; then
echo "Aborting"
exit 1
fi
echo "Proceeding..."
set -e
TEMP_WORKING_DIR=~/tmp/narayana/$CURRENT/sources/
mkdir -p $TEMP_WORKING_DIR
cd $TEMP_WORKING_DIR || fatal
for REPO in documentation quickstart performance narayana
do
echo ""
echo "=== TAGGING AND UPDATING $REPO ==="
echo ""
if ! [[ "$REPO" =~ 'github.com' ]]; then
REPO_TO_CLONE="git@github.com:jbosstm/$REPO.git"
else
# for repositories in different namespace than Narayana expecting the repo is followed by name of repository to be cloned to
REPO_TO_CLONE="$REPO"
REPO=${REPO##* }
fi
git clone $REPO_TO_CLONE || fatal
cd $REPO
git checkout $BRANCH || fatal
if [[ "$(uname)" == "Darwin" ]] # MacOS
then
find . -name \*.java -o -name \*.xml -o -name \*.template -o -name \*.properties -o -name \*.ent -o -name \INSTALL -o -name \README -o -name pre-release-vars.sh -o -name \*.sh -o -name \*.bat -o -name \*.cxx -o -name \*.c -o -name \*.cpp -o -iname \makefile | grep -v ".svn" | grep -v ".git" | grep -v target | grep -v .idea | xargs sed -i "" "s/$CURRENT_SNAPSHOT_VERSION/$CURRENT/g" || fatal
else
find . -name \*.java -o -name \*.xml -o -name \*.template -o -name \*.properties -o -name \*.ent -o -name \INSTALL -o -name \README -o -name pre-release-vars.sh -o -name \*.sh -o -name \*.bat -o -name \*.cxx -o -name \*.c -o -name \*.cpp -o -iname \makefile | grep -v ".svn" | grep -v ".git" | grep -v target | grep -v .idea | xargs sed -i "s/$CURRENT_SNAPSHOT_VERSION/$CURRENT/g" || fatal
fi
set +e
git status | grep "new\|deleted"
if [ $? -eq 0 ]
then
"Found new files changing to tag - very strange!"
exit
fi
set -e
# when there is nothing to commit then do not commit
toCommit=`git diff | wc -l`
if [ $toCommit -ge 1 ]; then
git commit -am "Updated to $CURRENT" || fatal
fi
git tag $CURRENT || fatal
if [[ "$(uname)" == "Darwin" ]] # MacOS
then
find . -name \*.java -o -name \*.xml -o -name \*.template -o -name \*.properties -o -name \*.ent -o -name \INSTALL -o -name \README -o -name pre-release-vars.sh -o -name \*.sh -o -name \*.bat -o -name \*.cxx -o -name \*.c -o -name \*.cpp -o -iname \makefile | grep -v ".svn" | grep -v ".git" | grep -v target | grep -v .idea | xargs sed -i "" "s/$CURRENT/$NEXT/g" || fatal
else
find . -name \*.java -o -name \*.xml -o -name \*.template -o -name \*.properties -o -name \*.ent -o -name \INSTALL -o -name \README -o -name pre-release-vars.sh -o -name \*.sh -o -name \*.bat -o -name \*.cxx -o -name \*.c -o -name \*.cpp -o -iname \makefile | grep -v ".svn" | grep -v ".git" | grep -v target | grep -v .idea | xargs sed -i "s/$CURRENT/$NEXT/g" || fatal
fi
set +e
git status | grep "new\|deleted"
if [ $? -eq 0 ]
then
"Found new files changing to new snapshot - very strange!"
exit
fi
set -e
toCommit=`git diff | wc -l`
if [ $toCommit -ge 1 ]; then
git commit -am "Updated to $NEXT" || fatal
fi
git push origin $BRANCH --tags || fatal
cd ..
done