Repository navigation
Expand file tree
/
Copy pathgit-release
More file actions
143 lines (123 loc) · 3.09 KB
/
Copy pathgit-release
File metadata and controls
143 lines (123 loc) · 3.09 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
set -e
FINISH_RELEASE=0
DO_MINOR=0
DO_MAJOR=0
EMCONF_PATH=
EMCONF_FILENAME=ext_emconf.php
while getopts ":hfe:-:" option; do
case "${option}" in
h)
echo "\
-h help \
-f finish release \
--minor increment minor \
--major increment major \
-e path to ext_emconf.php"
exit 1
;;
e)
EMCONF_PATH=${OPTARG}
;;
f)
FINISH_RELEASE=1
;;
-)
case ${OPTARG} in
"minor"*)
DO_MINOR=1
NEWTAG="$MAJOR.$MINORSTR$MINORINCREMENT.0"
;;
"major"*)
DO_MAJOR=1
DO_MINOR=0
NEWTAG="$MAJORSTR$MAJORINCREMENT.0.0"
;;
esac
esac
done
git fetch --all
if git rev-parse --quiet --verify master > /dev/null; then
git checkout master
else
git checkout -b master
fi
set +e
CURTAG=$(git describe --abbrev=0 --tags)
set -e
if [ -z $CURTAG ]
then
CURTAG="0.0.0"
fi
MAJOR=$(echo $CURTAG | sed -e 's/\.[a-z0-9\_\-]*\.[a-z0-9\_\-]*.*$//g')
MINOR=$(echo $CURTAG | sed -e 's/^[a-z0-9\_\-]*\.//g' | sed -e 's/\.[a-z0-9\_\-]*.*$//g')
PATCH=$(echo $CURTAG | sed -e 's/^.*\..*\.//g')
PATCHSTR=$(echo $PATCH | sed -e 's/[0-9]*$//g')
if [ ! -z $PATCHSTR ]
then
PATCHNR=$(echo $PATCH | sed "s/$PATCHSTR//g")
else
PATCHNR=$PATCH
fi
MINORSTR=$(echo $MINOR | sed -e 's/[0-9]*$//g')
if [ ! -z $MINORSTR ]
then
MINORNR=$(echo $MINOR | sed "s/$MINORSTR//g")
else
MINORNR=$MINOR
fi
MAJORSTR=$(echo $MAJOR | sed -e 's/[0-9]*$//g')
if [ ! -z $MAJORSTR ]
then
MAJORNR=$(echo $MAJOR | sed "s/$MAJORSTR//g")
else
MAJORNR=$MAJOR
fi
PATCHINCREMENT=$((($PATCHNR+1)))
MINORINCREMENT=$((($MINORNR+1)))
MAJORINCREMENT=$((($MAJORNR+1)))
NEWTAG="$MAJOR.$MINOR.$PATCHSTR$PATCHINCREMENT"
if [ "$DO_MINOR" == 1 ]; then
NEWTAG="$MAJOR.$MINORSTR$MINORINCREMENT.0"
fi
if [ "$DO_MAJOR" == 1 ]; then
NEWTAG="$MAJORSTR$MAJORINCREMENT.0.0"
fi
if git rev-parse --quiet --verify develop > /dev/null; then
git checkout develop
else
git checkout -b develop
fi
release_branch_name="release/$NEWTAG"
if git rev-parse --quiet --verify $release_branch_name > /dev/null; then
git checkout $release_branch_name
else
git checkout -b $release_branch_name
fi
release_note=$(git write-changelog | less | grep -m1 "" | sed "s;^\(.*\)\[\(.*\)\ (\(.*\)$;\[\2;")
git add ChangeLog
if [[ -f "$EMCONF_PATH$EMCONF_FILENAME" ]]; then
# Mac OSX
if [[ "$OSTYPE" == "darwin"* ]]; then
echo $OSTYPE
sed -i "" -e "s/version' =>.*/version' => '$NEWTAG',/" $EMCONF_PATH$EMCONF_FILENAME
else
sed -i -E "s/version' =>.*/version' => '$NEWTAG',/" $EMCONF_PATH$EMCONF_FILENAME
fi
git add $EMCONF_PATH$EMCONF_FILENAME
fi
echo "$release_note"
if set|grep '^release_note=' >/dev/null; then
git commit -m "$release_note"
else
git commit -m "[RELEASE] Release $NEWTAG"
fi
if [ "$FINISH_RELEASE" != 0 ]; then
git checkout develop
git merge --no-ff --no-edit $release_branch_name
git checkout master
git merge --no-ff --no-edit $release_branch_name
git tag $NEWTAG
git branch -d $release_branch_name
git checkout develop
fi