-
Notifications
You must be signed in to change notification settings - Fork 2
/
perform-release.sh
executable file
·179 lines (127 loc) · 5.27 KB
/
perform-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
#!/bin/bash
set -e
MVN_SETTINGS_PATH=${1-~/.m2/settings.xml}
build_branch=`git rev-parse --abbrev-ref HEAD`
echo "Building from branch: ${build_branch}"
git checkout $build_branch
unset RELEASE_VER
unset NEW_DEV_VER
release_properties_path=overture.release.properties
echo "Checking for ${release_properties_path}"
if [ -e "$release_properties_path" ]; then
echo "File exists: ${release_properties_path}"
export RELEASE_VER=$(head -n 1 $release_properties_path | tail -1 | cut -d'=' -f2)
export NEW_DEV_VER=$(head -n 2 $release_properties_path | tail -1 | cut -d'=' -f2)
else
echo "No release version information available!"
exit 1
fi
# remove all spaces in version numbers
export RELEASE_VER=${RELEASE_VER// }
export NEW_DEV_VER=${NEW_DEV_VER// }
echo "Fetch current version"
VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "Current version : ${VERSION}"
echo "Next dev version : ${NEW_DEV_VER}"
echo "Release version : ${RELEASE_VER}"
#Validate version number formats.
if ! echo $VERSION | grep '^[:0-9:]\+\.[:0-9:]\+\.[:0-9:]\+-SNAPSHOT$' > /dev/null
then
echo "Incorrect format for current version number."
exit 1
fi
if ! echo $RELEASE_VER | grep '^[:0-9:]\+\.[:0-9:]\+\.[:0-9:]\+$' > /dev/null
then
echo "Incorrect format for release version number."
exit 1
fi
if ! echo $NEW_DEV_VER | grep '^[:0-9:]\+\.[:0-9:]\+\.[:0-9:]\+-SNAPSHOT$' > /dev/null
then
echo "Incorrect format for new development version number."
exit 1
fi
echo "Cleaning old release artefacts"
mvn -Dmaven.repo.local=repository release:clean -q
echo "Prepare new release -DpushChanges=false"
mvn -Dmaven.repo.local=repository --batch-mode release:prepare -DreleaseVersion=${RELEASE_VER} -DdevelopmentVersion=${NEW_DEV_VER} -DpushChanges=false -s $MVN_SETTINGS_PATH
# > prepare.log
echo "The changes just done locally by 'release:prepare' do not change the IDE versions, so this will be fixed now"
git checkout Release/$RELEASE_VER
#fix the pom:
echo "Patch the ide/pom.xml with new parent version ${RELEASE_VER}, and old self version ${VERSION}"
sed -i{} "s|<version>${VERSION}</version>|<version>${RELEASE_VER}</version>|" ide/pom.xml
sed -i{} 's|</parent>|</parent>\
<version>'"${VERSION}"'</version>|' ide/pom.xml
echo "Tycho-versions set-version to: ${RELEASE_VER}"
mvn -Dmaven.repo.local=repository -Dtycho.mode=maven tycho-versions:set-version -DnewVersion=${RELEASE_VER} -f ide/pom.xml -q
echo "Add,commit, and squash commit for ide/* changes"
git add -u
git commit -m "Bump ide/ to version ${RELEASE_VER}"
# squash the last two commits
git reset --soft HEAD~2 && git commit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
echo "Reset tag: Release/${RELEASE_VER} to here"
# get last tag message
RTAGMSG=`git cat-file -p $(git rev-parse $(git tag -l | tail -n1)) | tail -n +6`
git tag -d Release/$RELEASE_VER
git tag -a Release/$RELEASE_VER -m "${RTAGMSG}"
# release tag modification completed
echo
echo "Release tag fixed"
echo
echo "Now do the same change for ${build_branch} with version ${NEW_DEV_VER}"
# now fix $build_branch
echo "Checkout the release tag as detached HEAD"
git checkout Release/$RELEASE_VER
echo "Pick last ${build_branch} commit: [maven-release-plugin] prepare for next development iteration'"
git cherry-pick $build_branch
#fix the pom:
echo "Patch the ide/pom.xml with new parent version ${NEW_DEV_VER}, and self version ${RELEASE_VER}"
sed -i{} "s|<version>${RELEASE_VER}</version>|<version>${NEW_DEV_VER}</version>|" ide/pom.xml
sed -i{} 's|</parent>|</parent>\
<version>'"${RELEASE_VER}"'</version>|' ide/pom.xml
mvn -Dmaven.repo.local=repository -Dtycho.mode=maven tycho-versions:set-version -DnewVersion=${NEW_DEV_VER} -f ide/pom.xml -q
echo "Add,commit, and squash commit for ide/* changes"
git add -u
git commit -m "Bump ide/ to version ${NEW_DEV_VER}"
# squash the last two commits
git reset --soft HEAD~2 && git commit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
#get sha for detached head
SHADEV=`git rev-parse HEAD`
echo "Checkout ${build_branch}"
git checkout $build_branch
echo "Nuke last two commits in ${build_branch}"
git reset --hard HEAD^^
echo "Rebase the corrected detached HEAD on top of ${build_branch}"
git rebase $SHADEV
## all branches/tags are now fixed using tycho set version
echo
echo "Git modifications required are now performed"
echo " - fixed ${build_branch}"
echo " - fixed Release/${RELEASE_VER}"
# perform the release
perform_action=none
if [ -z ${batchmode+x} ]; then
echo "interactive release mode"
read -p "Do you want to proceed with releasing the tag: Release/${RELEASE_VER}? (y/n?)" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
perform_action=release
fi
else
echo "batch mode: ${batch_mode}"
if [ $batchmode = "release" ]; then
perform_action=release
fi
fi
if [ $perform_action = "release" ]; then
echo "Git push --follow-tags"
git push --follow-tags
echo "Perform release with profile 'With-IDE'"
mvn -Dmaven.repo.local=repository --batch-mode release:perform -PWith-IDE -s $MVN_SETTINGS_PATH -DlocalCheckout=true
# > release.log
else
echo "Review local changed and manually run: 'git push --follow-tags && mvn -Dmaven.repo.local=repository release:perform' to release"
fi
echo
echo Done.