-
Notifications
You must be signed in to change notification settings - Fork 4
/
zanata-release-branching
executable file
·155 lines (136 loc) · 3.93 KB
/
zanata-release-branching
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
#!/bin/bash
### NAME
### zanata-release-branching - Do branching for big release (non-point release).
###
### SYNOPSIS
### zanata-release-branching [Options] <RepoName> <DevelopmentVersion>
###
### DESCRIPTION
### This script performs branching chores for big releases of
### zanata-platform.
###
### If branching succeeds and pushes to GitHub, it returns EXIT_OK (0).
### If branching succeeds but not pushed to GitHub,
### it returns EXIT_RETURN_FALSE (40).
export LC_ALL=C
set -eu
shopt -s globstar
ScriptDir=$(dirname $(readlink -q -f $0))
FunctionScriptFile=${ScriptDir}/zanata-functions
source "$FunctionScriptFile"
trap exit_print_error EXIT
##=== parsing Start ===
print_status -t parsing -s "Start"
BatchMode=0
JustUseCurrentDirectoryMode=0
PushMode=0
###
### OPTIONS
while getopts "hBjlp" opt;do
case $opt in
###
### -h: Show this help
h )
zanata_script_help $0
exit ${EXIT_OK}
;;
###
### -B: Batch mode
### It will NOT ask question and proceed with default choice.
B )
BatchMode=1
;;
###
### -j: Just use current directory
### This assumes that current directory is <RepoName> work directory,
### and correct branch is checked out.
j )
JustUseCurrentDirectoryMode=1
;;
###
### -p: Push after commit
### Git push when it has commit.
p )
PushMode=1
;;
* )
failed ${EXIT_FATAL_INVALID_OPTIONS} "$opt"
;;
esac
done
shift $((OPTIND-1))
export JustUseCurrentDirectoryMode
## Get RepoName
branch_prepare RELEASING "$@"
shift $ShiftOffset
print_status " RepoName=$RepoName"
## Get DevelopmentVersion
if [[ -z ${1-} ]];then
failed ${EXIT_FATAL_INVALID_OPTIONS} "Need <developmentVersion>"
fi
DevelopmentVersion=$1
if [[ $JustUseCurrentDirectoryMode -eq 0 ]];then
cd ${WORK_ROOT}/${RepoName}
fi
ArtifactId=$(get_artifact_id $RepoName)
##=== prepare Start ===
print_status -t prepare -s "Start"
print_status " Match master to remote"
git checkout master
branch_forced_pull
declare -A hasBranch
print_status " Determine branches to process"
for b in release ;do
case $(branch_does_exist $b) in
yes )
git checkout $b
;;
remote )
git checkout --track origin/$b
;;
* )
continue
;;
esac
print_status " match branch $b with origin for ${RepoName}"
branch_forced_pull
hasBranch[$b]=$b
done
if [ "${hasBranch[release]-}" = "" ];then
failed $EXIT_RETURN_FALSE "No release branch, skip"
fi
##=== branching Start ===
print_status -t "master->release" -s "Start"
git checkout "${hasBranch[release]}"
print_status " Point 'release' at local master"
if ! git merge master --ff-only; then
EXIT_MSG=" Please check for cherry-picked commits in release which were never merged into master"
exit ${EXIT_FATAL_FAIL}
fi
print_status -t "Final" -s "Start"
print_status " Update master version"
git checkout master
if [[ $DevelopmentVersion = 'auto' ]]; then
MasterProjectVersion=$(maven_project_version)
print_status " auto mode: Current project_version in master"
DevelopmentVersion=$(version_next $MasterProjectVersion 1)
print_status " New project_version in master is $DevelopmentVersion"
fi
$ScriptDir/zanata-pom-set-version $DevelopmentVersion build-tools,parent
if ! git diff --exit-code ;then
if [ $BatchMode -eq 0 ];then
read -p "### Press [Ctrl-C] to break, [Enter] to continue"
fi
git commit -a -m "chore(version): development version is now ${DevelopmentVersion}"
if [ $PushMode -ge 1 ];then
print_status " Push all the changes back"
git push origin master "${hasBranch[@]}"
else
exit ${EXIT_RETURN_FALSE}
fi
else
print_status " No change detected"
fi
cat>/dev/stderr<<END
Please remember to announce the branching in IRC and zanata-devel.
END