-
Notifications
You must be signed in to change notification settings - Fork 65
/
make-release.sh
executable file
·89 lines (71 loc) · 2.19 KB
/
make-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
#!/bin/bash
#
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
set -e
set -u
init() {
RED='\033[0;31m'
NC='\033[0m'
}
check() {
if [ $# -ne 2 ]; then
printf "%bError: %bWrong number of parameters.\nUsage: ./make-release.sh <version> <branch>\n" "${RED}" "${NC}"
exit 1
fi
}
apply_sed() {
SHORT_UNAME=$(uname -s)
if [ "$(uname)" == "Darwin" ]; then
sed -i '' "$1" "$2"
elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then
sed -i "$1" "$2"
fi
}
run() {
VERSION=$1
BRANCH_NAME=$2
GIT_REMOTE_UPSTREAM=upstream
GIT_REMOTE_FORK=origin
git checkout master
# reset local changes
while true; do
read -r -p "It will reset any local changes to the current branch ?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
git fetch ${GIT_REMOTE_UPSTREAM}
if git show-ref -q --heads "release"; then
git branch -D release
fi
# fetch latest changes from master branch
git pull ${GIT_REMOTE_UPSTREAM} master
# create a new local and push it to remote branch
git checkout -b ${BRANCH_NAME} master
git push ${GIT_REMOTE_UPSTREAM} ${BRANCH_NAME}
# Create VERSION file
echo "$VERSION" > VERSION
# replace nightly versions by release version
apply_sed "s#eclipse/che-server:nightly#eclipse/che-server:${VERSION}#g" src/constants.ts
apply_sed "s#quay.io/eclipse/che-operator:nightly#quay.io/eclipse/che-operator:${VERSION}#g" src/constants.ts
# now replace package.json dependencies
apply_sed "s;github.com/eclipse/che#\(.*\)\",;github.com/eclipse/che#${VERSION}\",;g" package.json
apply_sed "s;github.com/eclipse/che-operator#\(.*\)\",;github.com/eclipse/che-operator#${VERSION}\",;g" package.json
# add VERSION file to commit
git add VERSION src package.json yarn.lock
git commit -a -s -m "chore(release): release version ${VERSION}"
git push ${GIT_REMOTE_FORK} ${BRANCH_NAME}
}
init "$@"
check "$@"
run "$@"