forked from madnificent/docker-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·126 lines (111 loc) · 2.97 KB
/
release
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# Help information
if [ "$#" -eq 0 ]
then
echo "Usage: release ember-version"
echo ""
echo "releases a new version of the ember-docker."
echo ""
echo "To release version 2.5.1"
echo "> sh release 2.5.1"
echo ""
exit 0;
fi
# Helper functions
answerPositive(){
while true; do
read -p "$1 [Yn] " yn
case $yn in
[Yy]* ) exit 0;;
[Nn]* ) exit 1;;
"" ) exit 0;;
* ) answerPositive "$1";;
esac
done
}
if [[ "$OSTYPE" == "darwin"* ]]
then
SCRIPT_FOLDER=`dirname "$(readlink "$0")"`
else
SCRIPT_FOLDER=`dirname "$(readlink -f "$0")"`
fi
pushd "$SCRIPT_FOLDER/templates"
VERSION_NUMBER="$1"
FULL_VERSION="v$1"
if $(answerPositive "Continue building for $FULL_VERSION?")
then
echo "YAY"
else
popd
exit 1;
fi
if $(answerPositive "Create new files from template?")
then
for file in `find . -type f`
do
cp "$file" "../$file"
if [[ "$OSTYPE" == "darwin"* ]]
then
sed -i "" "s/@EMBER_VERSION/$VERSION_NUMBER/" ../$file
# https://stackoverflow.com/questions/6790631/use-the-contents-of-a-file-to-replace-a-string-using-sed
sed -i "" -e "/@SUPPORT_SCRIPTS/r ../support-scripts" -e "/@SUPPORT_SCRIPTS/d" ../$file
else
sed -i "s/@EMBER_VERSION/$VERSION_NUMBER/" ../$file
# https://stackoverflow.com/questions/6790631/use-the-contents-of-a-file-to-replace-a-string-using-sed
sed -i -e "/@SUPPORT_SCRIPTS/r ../support-scripts" -e "/@SUPPORT_SCRIPTS/d" ../$file
fi
done
else
echo "Not creating scripts... exiting"
exit 1;
fi
popd
if $(answerPositive "Set $VERSION_NUMBER as your default version?")
then
echo "Writing ember version to ~/.config/edi/settings"
if [ -r ~/.config/edi/settings ]
then
if [[ "$OSTYPE" == "darwin"* ]]
then
sed -i "" "s/VERSION=.*/VERSION=\"$VERSION_NUMBER\"/" ~/.config/edi/settings
else
sed -i "s/VERSION=.*/VERSION=\"$VERSION_NUMBER\"/" ~/.config/edi/settings
fi
else
mkdir -p ~/.config/edi
echo "VERSION=\"$VERSION_NUMBER\"" > ~/.config/edi/settings
fi
else
echo "Not changing settings in ~/.config/edi/settings"
fi
if $(answerPositive "Make local build of this version?")
then
docker build . -t madnificent/ember:$VERSION_NUMBER
else
echo "Not creating local build, continue with script"
fi
if $(answerPositive "Commit new version?")
then
git commit -a -m "Build for ember-cli $VERSION_NUMBER"
else
echo "Not creating new commit... exiting"
exit 1;
fi
if $(answerPositive "Create git tag $FULL_VERSION?")
then
git tag $FULL_VERSION
else
echo "Not creating new tag... exiting"
exit 1;
fi
if $(answerPositive "Push tag to origin?")
then
git push origin $FULL_VERSION
else
echo "Not pushing tag to origin... exiting"
exit 1;
fi
if $(answerPositive "Reset to previous commit?")
then
git reset HEAD^
fi