Skip to content

Commit c7e7c14

Browse files
authored
Merge pull request #2417, add release script (draft).
1 parent ba51bab commit c7e7c14

File tree

1 file changed

+279
-0
lines changed

1 file changed

+279
-0
lines changed

release.sh

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# set -e
18+
# set -x
19+
20+
function fail {
21+
>&2 echo "\033[31m\033[01m[
22+
FATAL ERROR:
23+
------------------
24+
$1 ]\033[0m"
25+
26+
echo "Clear current work dir"
27+
git add .
28+
git commit -m 'Failed preparation for release.'
29+
exit 1
30+
}
31+
32+
function fail_noclear {
33+
>&2 echo "\033[31m\033[01m[
34+
FATAL ERROR:
35+
------------------
36+
$1 ]\033[0m"
37+
exit 1
38+
}
39+
40+
function getProjectVersionFromPom {
41+
cat << EOF | xmllint --noent --shell pom.xml | grep content | cut -f2 -d=
42+
setns pom=http://maven.apache.org/POM/4.0.0
43+
xpath /pom:project/pom:version/text()
44+
EOF
45+
}
46+
47+
function generate_promotion_script {
48+
echo "Generating release promotion script 'promote-$version.sh'"
49+
read -d '' script <<- EOF
50+
#!/bin/bash
51+
echo "Promoting release $version
52+
Actions about to be performed:
53+
------------------------------
54+
\$(cat \$0 | tail -n +14)
55+
------------------------------------------"
56+
read -p "Press enter to continue or CTRL-C to abort"
57+
# promote the source distribution by moving it from the staging area to the release area
58+
# mv https://dist.apache.org/repos/dist/dev/incubator/dubbo/$version https://dist.apache.org/repos/dist/release/incubator/dubbo/ -m "Upload release to the mirrors"
59+
#mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:rc-release -DstagingRepositoryId=$stagingRepositoryId -DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-nexus-staging -Ddescription="Release vote has passed"
60+
# Renumber the next development iteration $next_version:
61+
git checkout $branch
62+
mvn release:update-versions --batch-mode
63+
mvn versions:set versions:commit -DprocessAllModules=true -DnewVersion=$next_version
64+
git add --all
65+
git commit -m 'Start the next development version'
66+
echo "
67+
Please check the new versions and merge $branch to the base branch.
68+
"
69+
EOF
70+
71+
echo "$script" > promote-$version.sh
72+
chmod +x promote-$version.sh
73+
git add promote-$version.sh
74+
}
75+
76+
function generate_rollback_script {
77+
echo "Generating release rollback script 'revert-$version.sh'"
78+
read -d '' script <<- EOF
79+
#!/bin/bash
80+
echo -n "Reverting release $version
81+
Actions about to be performed:
82+
------------------------------
83+
\$(cat \$0 | tail -n +14)
84+
------------------------------------------
85+
Press enter to continue or CTRL-C to abort"
86+
read
87+
# clean up local repository
88+
git checkout $GIT_BRANCH
89+
git branch -D $branch
90+
git tag -d $tag
91+
# clean up staging dist area
92+
#svn rm https://dist.apache.org/repos/dist/dev/incubator/dubbo/$version -m "Release vote has failed"
93+
# clean up staging maven repository
94+
#mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:rc-drop -DstagingRepositoryId=$stagingrepoid -DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-nexus-staging -Ddescription="Release vote has failed"
95+
# clean up remaining release files
96+
find . -name "*.releaseBackup" -exec rm {} \\;
97+
[ -f release.properties ] && rm release.properties
98+
EOF
99+
echo "$script" > revert-$version.sh
100+
101+
chmod +x revert-$version.sh
102+
git add revert-$version.sh
103+
}
104+
105+
function generate_release_vote_email {
106+
107+
echo "Generating Vote email"
108+
109+
echo "
110+
Hello Dubbo Community,
111+
112+
This is a call for vote to release Apache Dubbo (Incubating) version $version.
113+
114+
The release candidates (RC5):
115+
https://dist.apache.org/repos/dist/dev/incubator/dubbo/$version
116+
117+
Git tag for the release (RC5):
118+
https://github.com/apache/incubator-dubbo/tree/dubbo-$version
119+
Hash for the release tag:
120+
3963d8fd93642398375ea92acb7ed4d2bc1b0518
121+
122+
Release Notes:
123+
https://github.com/apache/incubator-dubbo/blob/dubbo-$version/CHANGES.md
124+
125+
The artifacts have been signed with Key : 28681CB1, which can be found in the keys file:
126+
https://dist.apache.org/repos/dist/dev/incubator/dubbo/KEYS
127+
128+
The vote will be open for at least 72 hours or until necessary number of votes are reached.
129+
130+
Please vote accordingly:
131+
132+
[ ] +1 approve
133+
[ ] +0 no opinion
134+
[ ] -1 disapprove with the reason
135+
136+
" | tail -n+2 > release-vote.txt
137+
138+
git add release-vote.txt
139+
}
140+
141+
hasFileChanged=`git status|grep -e "nothing to commit, working tree clean"|wc -l`
142+
if [ $hasFileChanged -lt 1 ] ; then
143+
fail_noclear "ERROR: there are changes that have not committed in current branch ."
144+
fi
145+
146+
if [ ! $( git config --get remote.staging.url ) ] ; then
147+
fail "
148+
No staging remote git repository found. The staging repository is used to temporarily
149+
publish the build artifacts during the voting process. Since no staging repository is
150+
available at Apache, it is best to use a git mirror on your personal github account.
151+
First fork the github Apache Dubbo (Incubating) mirror (https://github.com/apache/dubbo) and then
152+
add the remote staging repository with the following command:
153+
$ git remote add staging git@github.com:<your personal github username>/dubbo.git
154+
$ git fetch staging
155+
$ git push staging
156+
This will bring the staging area in sync with the origin and the release script can
157+
push the build branch and the tag to the staging area.
158+
"
159+
fi
160+
161+
162+
echo "Cleaning up any release artifacts that might linger: mvn -q release:clean"
163+
mvn -q release:clean
164+
165+
# the branch on which the code base lives for this version
166+
read -p 'Input the branch on which the code base lives for this version: ' GIT_BRANCH
167+
168+
version=$(getProjectVersionFromPom)
169+
while [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-M[0-9]+)?$ ]]
170+
do
171+
read -p "Version to release (in pom now is $version): " -e t1
172+
if [ -n "$t1" ]; then
173+
version="$t1"
174+
fi
175+
done
176+
177+
tag=dubbo-$version
178+
branch=$version-release
179+
180+
major_version=$(expr $version : '\(.*\)\..*\..*')
181+
minor_version=$(expr $version : '.*\.\(.*\)\..*')
182+
bugfix_version=$(expr $version : '.*\..*\.\(.*\)')
183+
184+
next_version="$major_version.$minor_version.$(expr $bugfix_version + 1)-SNAPSHOT"
185+
previous_minor_version=$(expr $bugfix_version - 1)
186+
if [ $previous_minor_version -lt 0 ] ; then
187+
previous_version="$major_version.$minor_version.0-SNAPSHOT"
188+
else
189+
previous_version="$major_version.$minor_version.$(expr $bugfix_version - 1)"
190+
fi
191+
192+
log=../release.out
193+
194+
if [ -f $log ] ; then
195+
rm $log
196+
fi
197+
198+
echo "Removing previous release tag $tag (if exists)"
199+
oldtag=`git tag -l |grep -e "$tag"|wc -l` >> $log
200+
[ "$oldtag" -ne 0 ] && git tag -d $tag >> $log
201+
202+
echo "Removing previous build branch $branch (if exists)"
203+
oldbranch=`git branch |grep -e "$branch"|wc -l` >> $log
204+
[ "$oldbranch" -ne 0 ] && git branch -D $branch >> $log
205+
206+
echo "Removing previous staging tag (if exists)"
207+
git push origin :refs/tags/$tag >> $log
208+
209+
echo "Creating release branch"
210+
releasebranch=`git branch -a |grep -e "origin/$branch$"|wc -l` >> $log
211+
if [ $releasebranch -ne 0 ]
212+
then
213+
echo "git checkout -b $branch origin/$branch"
214+
read -p "test"
215+
git checkout -b $branch origin/$branch >> $log
216+
if [ $? -ne 0 ] ; then
217+
fail_noclear "ERROR: git checkout -b $branch origin/$branch"
218+
fi
219+
else
220+
echo "git checkout -b $branch origin/$GIT_BRANCH"
221+
read -p "test"
222+
git checkout -b $branch origin/$GIT_BRANCH >> $log
223+
if [ $? -ne 0 ] ; then
224+
fail_noclear "ERROR: git checkout -b $branch origin/$GIT_BRANCH"
225+
fi
226+
fi
227+
228+
# Change version from SNAPSHOT to release ready
229+
#mvn versions:set versions:commit -DprocessAllModules=true -DnewVersion=$version
230+
# Add tag
231+
#git tag -a dubbo-$version -m "generate tag dubbo-version" >> $log
232+
#git push origin dubbo-$version >> $log
233+
#mvn release:prepare -Darguments="-DskipTests" -DautoVersionSubmodules=true -Dusername=chickenlj -DupdateWorkingCopyVersions=true -DpushChanges=false -DdryRun=true
234+
#if [ $? -ne 0 ] ; then
235+
# fail "ERROR: mvn release:prepare was not successful"
236+
#fi
237+
#mvn -Prelease release:perform -Darguments="-DskipTests -Dmaven.deploy.skip=true" -DautoVersionSubmodules=true -Dusername=chickenlj -DdryRun=true
238+
#if [ $? -ne 0 ] ; then
239+
# fail "ERROR: mvn release:perform was not successful"
240+
#fi
241+
mvn versions:set versions:commit -DprocessAllModules=true -DnewVersion=$version >> $log
242+
243+
# Determine the staging repository and close it after deploying the release to the staging area
244+
stagingrepoid=$(mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:rc-list -DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-nexus-staging | grep -v "CLOSED" | grep -Eo "(comalibaba-\d+)";)
245+
246+
echo "Closing staging repository with id $stagingrepoid"
247+
#mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:rc-close -DstagingRepositoryId=$stagingrepoid -DnexusUrl=https://oss.sonatype.org/ -DserverId=sonatype-nexus-staging -Ddescription="Release has been built, awaiting vote"
248+
249+
read -p "test"
250+
#mvn clean install -DskipTests
251+
cd ./distribution
252+
echo "Current dir: $(pwd)"
253+
echo "Prepare for source and binary releases: mvn install -Prelease"
254+
mvn install -Prelease >> $log
255+
if [ $? -ne 0 ] ; then
256+
fail "ERROR: mvn clean install -Prelease"
257+
fi
258+
cd ./target
259+
shasum -a 512 apache-dubbo-incubating-${version}-source-release.zip >> apache-dubbo-incubating-${version}-source-release.zip.sha512
260+
shasum -a 512 apache-dubbo-incubating-${version}-bin-release.zip >> apache-dubbo-incubating-${version}-bin-release.zip.sha512
261+
262+
echo "Submit all release candidate packages to svn"
263+
#svn mkdir https://dist.apache.org/repos/dist/dev/incubator/dubbo/$version-test -m "Create $version release staging area"
264+
#svn co --force --depth=empty https://dist.apache.org/repos/dist/dev/incubator/dubbo/$version .
265+
#svn add *
266+
#svn commit -m "Upload dubbo-$version to staging area"
267+
268+
cd ../..
269+
git add .
270+
git commit -m "Prepare for release $version"
271+
git push origin $branch
272+
273+
generate_promotion_script
274+
generate_rollback_script
275+
generate_release_vote_email
276+
git checkout -b $branch-staging
277+
git add .
278+
git commit -m "Prepare for release $version"
279+
git push staging $branch-staging

0 commit comments

Comments
 (0)