forked from riuvshin/release
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·235 lines (210 loc) · 8.83 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
set -e
clone() {
for PROJECT in ${PROJECT_LIST[@]}; do
if [ -d ${PROJECT} ]; then
echo -e "\x1B[92m${PROJECT}\x1B[0m already exist, performing git pull"
cd ${PROJECT}
git checkout ${BRANCH}
git pull
cd ../
else
echo -e "Cloning \x1B[92m${PROJECT}\x1B[0m repo"
case ${PROJECT} in
che-ide-extension|che-ide-server-extension|che-plugin-menu|che-plugin-wizard|che-plugin-json|che-plugin-embedjs)
echo -e "Cloning \x1B[92m${PROJECT}\x1B[0m repo from \x1B[92mCHE-SAMPLES\x1B[0m"
git clone [email protected]:che-samples/${PROJECT}.git
;;
*)
echo -e "Cloning \x1B[92m${PROJECT}\x1B[0m repo from \x1B[92mECLIPSE\x1B[0m"
git clone [email protected]:eclipse/${PROJECT}.git
;;
esac
cd ${PROJECT}
git checkout ${BRANCH}
cd ../
fi
done
}
updateParent() {
mvn versions:update-parent versions:commit -DallowSnapshots=true -DparentVersion=[$1]
}
updateDependencies() {
NEW_VER=$1 && shift
PROP_LIST=($@)
for i in ${PROP_LIST[@]}
do
version_old=$(grep -m 1 ${i} pom.xml | awk '{print $1}')
version_new="<${i}>${NEW_VER}</${i}>"
sed -i -e "s#$version_old#$version_new#" pom.xml
done
}
createBranches() {
for PROJECT in ${PROJECT_LIST[@]}; do
echo -e "\x1B[92m create $1 branch in ${PROJECT}\x1B[0m"
cd ${PROJECT}
git branch $1
git push --set-upstream origin $1
cd ../
done
}
pushChanesWithMaven() {
echo -e "\x1B[92m Push changes with maven into $3 branch\x1B[0m"
mvn scm:update scm:checkin scm:update -Dincludes=$1 -Dmessage="$2" -DpushChanges=true -D=scmVersionType=branch -DscmVersion=$3
}
setNextDevelopmentVersionInMaster() {
if [ -z "${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}" ]; then
echo "RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER is not set, exit."
exit 2
fi
resolveVersions
NEXT_TAG_VER=$(echo ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER} | sed -e 's#-SNAPSHOT##')
for PROJECT in ${PROJECT_LIST[@]}; do
echo -e "\x1B[92m set next development version in master of ${PROJECT} project\x1B[0m"
cd ${PROJECT}
git checkout $1
mvn versions:set -DnewVersion=${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER} -DgenerateBackupPoms=false
if [ ${PROJECT} == "che-parent" ]; then
mvn clean install
elif [ ${PROJECT} == "che-lib" ]; then
updateParent ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
elif [ ${PROJECT} == "che-docs" ]; then
updateParent ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
elif [ ${PROJECT} == "che" ]; then
updateParent ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
updateDependencies ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER} ${CHE_PROPERTIES_LIST[@]}
#mvn clean install -N
# update dockerfiles
#cp -r dockerfiles/cli/version/$VERSION dockerfiles/cli/version/$NEXT_TAG_VER
#sed -i -e "s#$VERSION#$NEXT_TAG_VER#" dockerfiles/cli/version/${NEXT_TAG_VER}/images
#sed -i -e "s#$VERSION#$NEXT_TAG_VER#" dockerfiles/cli/version/${NEXT_TAG_VER}/images-bootstrap
#sed -i -e "s#$VERSION#$NEXT_TAG_VER#" dockerfiles/cli/version/${NEXT_TAG_VER}/images-stacks
#sed -i -e "s#$VERSION#$NEXT_TAG_VER#" dockerfiles/cli/version/${NEXT_TAG_VER}/images-utilities
#sed -i -e "s#.*#$VERSION#" dockerfiles/cli/version/latest.ver
#sed -i -e "s#>.*-SNAPSHOT#>$RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER#" dockerfiles/lib/dto-pom.xml
sed -i -e "s#>.*-SNAPSHOT#>$RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER#" typescript-dto/dto-pom.xml
git add .
#elif [[ ${project} == *"extension"* ]]; then
# updateParent ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
# setDepsVersions ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER} ${CHE_EXTENSIONS_PROPERIES_LIST[@]}
#elif [[ ${project} == *"plugin"* ]]; then
# updateParent ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
# setDepsVersions ${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER} ${CHE_PLUGINS_PROPERIES_LIST[@]}
fi
pushChanesWithMaven . "RELEASE: Set next development version" $1
cd ../
done
}
resolveVersions() {
if [[ -z "${RELEASE_VERSION}" ]] || [[ -z "${RELEASE_NEXT_VERSION}" ]] ; then
echo "RELEASE_VERSION and RELEASE_NEXT_VERSION must be set in ENV"
exit 1
else
VERSION=${RELEASE_VERSION}
NEXT_DEV_VERSION=${RELEASE_NEXT_VERSION}
fi
echo -e "\x1B[92m############### RELEASE VERSION: ${VERSION}\x1B[0m"
echo -e "\x1B[92m############### NEXT DEV VERSION: ${NEXT_DEV_VERSION}\x1B[0m"
}
setDepsVersions() {
local VERSION_OF_DEPS=$1 && shift
local DEPS_LIST=($@)
echo -e "\x1B[92m############### Update dependencies versions.\x1B[0m"
updateDependencies $VERSION_OF_DEPS ${DEPS_LIST[@]}
pushChanesWithMaven pom.xml "RELEASE: Update dependencies versions" ${RELEASE_BRANCH_NAME}
}
setParentVersion() {
echo -e "\x1B[92m############### Update parent pom version in $1\x1B[0m"
updateParent $2
pushChanesWithMaven pom.xml "RELEASE: Update parent pom version" ${RELEASE_BRANCH_NAME}
}
releaseProject() {
echo -e "\x1B[92m############### Release: $1\x1B[0m"
mvn release:prepare release:perform -Dresume=false -Dtag=$2 -DdevelopmentVersion=$3 -DreleaseVersion=$2 "-Darguments=-DskipTests=true -Dskip-validate-sources -Dgpg.passphrase=${GPG_PASSPHRASE} -Darchetype.test.skip=true -Dversion.animal-sniffer.enforcer-rule=1.16"
}
set_tags_in_che_dockerfiles_for_release() {
THEIA_VERSION="$(curl -s https://raw.githubusercontent.com/eclipse/che-theia/master/dockerfiles/theia/Dockerfile | grep "ARG THEIA_VERSION=" | cut -d '=' -f2)-$VERSION"
#sed -i -e "s#.*#$VERSION#" dockerfiles/cli/version/latest.ver
#sed -i -e "s#-SNAPSHOT##" dockerfiles/lib/dto-pom.xml
#sed -i -e "s#-SNAPSHOT##" typescript-dto/dto-pom.xml
#sed -i -e "s#eclipse/che-ip:.*#eclipse/che-ip:$VERSION#" deploy/openshift/ocp.sh
sed -i -e "s#nightly#$VERSION#" deploy/openshift/deploy_che.sh
pushChanesWithMaven . "RELEASE: Set tags in Dockerfiles" ${RELEASE_BRANCH_NAME}
}
release() {
for project in ${PROJECT_LIST[@]}
do
cd ${project}
git checkout ${RELEASE_BRANCH_NAME}
if [ ${project} == "che-parent" ]; then
releaseProject ${project} ${VERSION} ${NEXT_DEV_VERSION}
mvn clean install
elif [ ${project} == "che" ]; then
set_tags_in_che_dockerfiles_for_release
setParentVersion ${project} ${VERSION}
setDepsVersions ${VERSION} ${CHE_PROPERTIES_LIST[@]}
releaseProject ${project} ${VERSION} ${NEXT_DEV_VERSION}
setDepsVersions ${NEXT_DEV_VERSION} ${CHE_PROPERTIES_LIST[@]}
setParentVersion ${project} ${NEXT_DEV_VERSION}
#mvn clean install -N
#elif [[ ${project} == *"extension"* ]]; then
# setParentVersion ${project} ${VERSION}
# setDepsVersions ${VERSION} ${CHE_EXTENSIONS_PROPERIES_LIST[@]}
# releaseProject ${project} ${VERSION} ${NEXT_DEV_VERSION}
# setDepsVersions ${NEXT_DEV_VERSION} ${CHE_EXTENSIONS_PROPERIES_LIST[@]}
# setParentVersion ${project} ${NEXT_DEV_VERSION}
#elif [[ ${project} == *"che-plugin"* ]]; then
# setParentVersion ${project} ${VERSION}
# setDepsVersions ${VERSION} ${CHE_PLUGINS_PROPERIES_LIST[@]}
# releaseProject ${project} ${VERSION} ${NEXT_DEV_VERSION}
# setDepsVersions ${NEXT_DEV_VERSION} ${CHE_PLUGINS_PROPERIES_LIST[@]}
# setParentVersion ${project} ${NEXT_DEV_VERSION}
else
setParentVersion ${project} ${VERSION}
releaseProject ${project} ${VERSION} ${NEXT_DEV_VERSION}
setParentVersion ${project} ${NEXT_DEV_VERSION}
fi
cd ..
done
}
cleanUp() {
for project in ${PROJECT_LIST[@]}
do
rm -rf ${project}
done
}
prepareRelease() {
cleanUp
clone
createBranches ${RELEASE_BRANCH_NAME}
createBranches set_next_version_in_master_${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
setNextDevelopmentVersionInMaster set_next_version_in_master_${RELEASE_NEXT_DEVELOPMENT_VERSION_IN_MASTER}
}
performRelease() {
cleanUp
clone
resolveVersions
release
}
CHE_PROPERTIES_LIST=(
che.docs.version
che.lib.version
che.version
che.dashboard.version
)
CHE_EXTENSIONS_PROPERIES_LIST=(
che.version
)
CHE_PLUGINS_PROPERIES_LIST=(
che.version
)
# KEEP CORRECT ORDER!
#PROJECT_LIST=(
#che-parent
#che-lib
#che-docs
#che )
PROJECT_LIST=("${@:3}")
GPG_PASSPHRASE=$2
############################
$1