-
Notifications
You must be signed in to change notification settings - Fork 24
/
build_release.sh
executable file
·82 lines (74 loc) · 3.13 KB
/
build_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
#!/bin/bash
if [ $# == 1 ]; then
#Automate release number change in configure.ac
DOTTEDVERSION=$(echo $1 | sed s/-/./g)
MYREGEXP='[0-9+\.]+'
EMAILREGEXP='([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})'
URLREGEXP='(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/[a-zA-Z0-9\-\.]*)*'
PREVLINE=$(grep -E 'AC_INIT\(\[igor\]\,\ \['$MYREGEXP'\]\,\ \['$EMAILREGEXP'\]\,\ \[igor\]\,\ \['$URLREGEXP'\]\)' configure.ac)
NEWLINE=$(grep -E 'AC_INIT\(\[igor\]\,\ \['$MYREGEXP'\]\,\ \['$EMAILREGEXP'\]\,\ \[igor\]\,\ \['$URLREGEXP'\]\)' configure.ac | sed -r s/$MYREGEXP/$DOTTEDVERSION/)
#Now replace it in configure.ac
#reescape everything
ZZ=$(echo $PREVLINE | sed s/'\['/'\\['/g) #escape opening bracket
ZZ=$(echo $ZZ | sed s/'\]'/'\\]'/g) #escape closing bracket
ZZ=$(echo $ZZ | sed s/'\.'/'\\.'/g) #escape backslash
ZZ=$(echo $ZZ | sed 's/)/\\)/g') #escape closing parenthesis
ZZ=$(echo $ZZ | sed 's/(/\\(/g') #escape opening parenthesis
ZZ=$(echo $ZZ | sed 's/\:/\\:/g') #escape colum
ZZ=$(echo $ZZ | sed 's/\ /\\ /g') #escape spaces
#ZZ=$(echo $ZZ | sed 's/\//\\//g') #escape forward slashes => removed as changing the delimiters to = in the next line is cleaner
sed -r "s=$ZZ=$NEWLINE=" configure.ac > tmpfile
rm configure.ac
mv tmpfile configure.ac
#Automatic release number change in README.md
sed -r s/'Latest released version: '[0-9\.]+/'Latest released version: '$DOTTEDVERSION/ ./docs/asciidoc/version.adoc > ./docs/asciidoc/tmpfile
rm ./docs/asciidoc/version.adoc
mv ./docs/asciidoc/tmpfile ./docs/asciidoc/version.adoc
#Automatic release number change in pygor setup.py
sed -r s/'version=\"'[0-9\.]+/'version=\"'$DOTTEDVERSION/ ./pygor/setup.py > ./pygor/tmpfile
rm ./pygor/setup.py
mv ./pygor/tmpfile ./pygor/setup.py
#Update HTML documentation for github pages website
./build_igor_asciidoc.sh
#Commit
echo "Do you wish to commit the changes made during release creation?"
echo "Enter the digit corresponding to your choice:"
select yn in Yes No
do
case $yn in
Yes)
git add configure.ac;
git add ./docs/asciidoc/version.adoc
git add ./docs/index.html
git add ./pygor/setup.py
COMMITMESSAGE="IGoR v"$DOTTEDVERSION" release commit."
git commit -m "$COMMITMESSAGE"
break;;
No)
echo "Not commiting release creation..."
break;;
esac
done
#Create the packaged archive
MYPATH=$(pwd)
NEWDIRPATH=$MYPATH/../igor_$1
echo Copying repository as $NEWDIRPATH...
cp -r $MYPATH $NEWDIRPATH
echo Removing all git related stuff inside
rm -rf $NEWDIRPATH/.git*
cd $NEWDIRPATH
bash autogen.sh
./configure
make distclean
cd ..
zip -r -D igor_$1.zip ./igor_$1
echo Cleaning up temporary directory...
rm -rf $NEWDIRPATH
echo IGoR v$DOTTEDVERSION release successfully created!
elif [ $# == 0 ]; then
echo No release number has been provided... Leaving without performing any action
echo Please provide a release number as argument with dash seperated version number e.g 5-2-3
else
echo Too many arguments were passed
echo Please provide only the release number as argument
fi