forked from project-ncl/cleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
79 lines (60 loc) · 1.84 KB
/
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
#!/bin/bash -xe
set -e
repository="project-ncl/cleaner"
tagprefix=""
testparams=""
releaseparams=""
#######
if [ $# -lt 2 ]; then
echo "You have to enter new version and RC version" >&2
exit 1
fi
version=$1
if ! echo $version | grep -q "^[1-9][0-9]*\.[0-9]\+\.[0-9]\+$"; then
echo "The version has to be in format X.Y.Z"
exit 1
fi
changes=`git status --porcelain | grep -v "^??" | wc -l`
if [ $changes -gt 0 ]; then
echo "You have uncommited changes."
exit 1
fi
rc=$2
upstream=`git remote -v | grep "$repository" | cut -f1 | head -n1`
tag="$tagprefix$version"."$2"
majmin=`echo $version | cut -f1,2 -d.`
micro=`echo $version | cut -f3 -d.`
nextversion="$majmin.$(( micro + 1 ))-SNAPSHOT"
branch="v$majmin"
#Remove snapshot from Orch dependency
sed -i "s/<pnc.version>\([0-9].[0-9].[0-9]\)-SNAPSHOT<\/pnc.version>/<pnc.version>\1<\/pnc.version>/" pom.xml
echo "Checking out to branch $upstream/$branch"
git fetch $upstream
git checkout $upstream/$branch
echo "Testing build"
mvn clean install $testparams
echo "Seting up new version"
mvn versions:set -DnewVersion=$version
mvn versions:commit
sed -i "s/<tag>HEAD<\/tag>/<tag>$tag<\/tag>/" pom.xml
echo "Commiting changed pom files"
git add pom.xml
git commit -m "Release version $version"
echo "Deploing artifacts"
GPG_TTY=$(tty)
export GPG_TTY
mvn clean deploy -DskipTests -Prelease $releaseparams -Dgpg.executable=`which gpg2`
echo "Tagging release"
git tag $tag
#echo "Preparing for next development"
#mvn versions:set -DnewVersion=$nextversion
#mvn versions:commit
#sed -i "s/<tag>$tag<\/tag>/<tag>HEAD<\/tag>/" pom.xml
#git add pom.xml
#git commit -m "Preparing for next development"
echo
echo
echo "Release prepared. Check everything!"
echo "Then go to https://oss.sonatype.org/ and release the staging repository."
echo "When everything is done, don't forget to push:"
echo " git push $upstream $tag"