forked from borisskert/release-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotfix_finish.sh
executable file
·101 lines (79 loc) · 2.77 KB
/
hotfix_finish.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
#!/bin/bash
set -e
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -f "${SCRIPT_PATH}/.version.sh" ]; then
source ${SCRIPT_PATH}/.version.sh
else
VERSION="UNKNOWN VERSION"
fi
echo "Release scripts (hotfix-finish, version: ${VERSION})"
if [ -f "${SCRIPT_PATH}/.common-util.sh" ]; then
source ${SCRIPT_PATH}/.common-util.sh
else
echo 'Missing file .common-util.sh. Aborting'
exit -1
fi
if [ $# -ne 2 ]
then
echo 'Usage: hotfix_finish.sh <hotfix-version> <next-snapshot-version>'
echo 'For example:'
echo 'hotfix_finish.sh 0.2.1 0.3.0'
exit 2
fi
HOTFIX_VERSION=$1
NEXT_VERSION=$2
HOTFIX_BRANCH=`format_hotfix_branch_name "$HOTFIX_VERSION"`
if [ ! "$HOTFIX_BRANCH" = "$CURRENT_BRANCH" ]
then
echo "Please checkout the branch '$HOTFIX_BRANCH' before processing this hotfix release."
exit 1
fi
check_local_workspace_state "hotfix_finish"
git checkout $HOTFIX_BRANCH && git pull $REMOTE_REPO
build_snapshot_modules
cd ${GIT_REPO_DIR}
git reset --hard
set_modules_version $HOTFIX_VERSION
cd ${GIT_REPO_DIR}
if ! is_workspace_clean
then
# commit hotfix versions
git commit -am "Release hotfix $HOTFIX_VERSION"
else
echo "Nothing to commit..."
fi
build_release_modules
cd ${GIT_REPO_DIR}
git reset --hard
# merge current hotfix into master
git checkout ${MASTER_BRANCH} && git pull ${REMOTE_REPO}
git merge --no-edit ${HOTFIX_BRANCH}
# create release tag
HOTFIX_TAG=`format_release_tag "${HOTFIX_VERSION}"`
git tag -a "${HOTFIX_TAG}" -m "Release ${HOTFIX_VERSION}"
git checkout ${HOTFIX_BRANCH}
# prepare next snapshot version
NEXT_SNAPSHOT_VERSION=`format_snapshot_version "${NEXT_VERSION}"`
set_modules_version "${NEXT_SNAPSHOT_VERSION}"
cd ${GIT_REPO_DIR}
if ! is_workspace_clean
then
# commit next snapshot versions
git commit -am "Start next iteration with ${NEXT_SNAPSHOT_VERSION} after hotfix ${HOTFIX_VERSION}"
else
echo "Nothing to commit..."
fi
# merge next snapshot version into develop
git checkout ${DEVELOP_BRANCH}
if git merge --no-edit ${HOTFIX_BRANCH}
then
echo "# Okay, now you've got a new tag and commits on ${MASTER_BRANCH} and ${DEVELOP_BRANCH}"
echo "# Please check if everything looks as expected and then push."
echo "# Use this command to push all at once or nothing, if anything goes wrong:"
echo "git push --atomic ${REMOTE_REPO} ${MASTER_BRANCH} ${DEVELOP_BRANCH} ${HOTFIX_BRANCH} --follow-tags # all or nothing"
else
echo "# Okay, you have got a conflict while merging onto ${DEVELOP_BRANCH}"
echo "# but don't panic, in most cases you can easily resolve the conflicts (in some cases you even do not need to merge all)."
echo "# Please do so and continue the hotfix finishing with the following command:"
echo "git push --atomic ${REMOTE_REPO} ${MASTER_BRANCH} ${DEVELOP_BRANCH} ${HOTFIX_BRANCH} --follow-tags # all or nothing"
fi