forked from infinitest/infinitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·61 lines (50 loc) · 1.81 KB
/
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
#!/bin/sh
abspath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
project_root=`dirname ${abspath}`
main_site=${project_root}/../infinitest.github.com
update_site=${main_site}
# Test for web project existence
if [ ! -e ${main_site} ]; then
echo "You should clone infinitest.github.com project at the same level as infinitest project."
exit 1
fi
# Ask for version summary
echo "Please enter the newsfeed summary for this release:"
read release_message
# Clean working directory
rm -Rf .privatebuild > /dev/null
cd ${project_root}
git stash save --quiet "Before publish"
git clean -xdf
# Increment Version
CURRENT=`grep "<version>" -i pom.xml --max-count 1 | sed -e "s/.*<version>\(.*\)<\/version>/\1/" | sed -e "s/-SNAPSHOT//"`
MAJOR_VERSION=`echo $CURRENT | sed -e "s/\([0-9]*\.[0-9]*\.\)\([0-9]*\)/\1/"`
MINOR_VERSION=`echo $CURRENT | sed -e "s/\([0-9]*\.[0-9]*\.\)\([0-9]*\)/\2/"`
NEXT=$MAJOR_VERSION`expr $MINOR_VERSION + 1`-SNAPSHOT
find . -name "*.xml" | xargs perl -pi -e "s/${CURRENT}-SNAPSHOT/${NEXT}/g"
git stash save "Preparing ${NEXT}"
find . -name "*.xml" | xargs perl -pi -e "s/${CURRENT}-SNAPSHOT/${CURRENT}/g"
# Commit main project
git commit -am "VERSION${CURRENT} - ${release_message}"
# Build it!
mvn clean install
if [ "$?" -ne 0 ]; then
echo "ERROR> Maven build failed aborting."
git reset --hard HEAD~1
exit 1
fi
# Prepare next version
git stash pop --quiet
git checkout --theirs "*.xml"
git commit -am "${NEXT}"
# Publish web site
cd ${main_site}
git clean -df
cp -r ${project_root}/infinitest-eclipse/target/update_site/* ${update_site}
printf "\n\n%s %s %s" "`date`" ${CURRENT} "${release_message}" >> ${update_site}/ReleaseNotes.txt
cd ${update_site}
ruby update_rss.rb ${CURRENT} "${release_message}"
rm update_rss.rb
cd ${main_site}
git add .
git commit -am "VERSION${CURRENT} - ${release_message}"