-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·65 lines (54 loc) · 1.83 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
#!/usr/bin/env bash
set -o errexit
RELEASE_BRANCH="release"
DEVELOP_BRANCH="master"
TAG_PREFIX="retrofit-jenkins-api"
WORK_PREFIX="rel"
#Make sure two arguments are provided
if [ "$#" != "2" ]; then
echo "2 arguments must be provided:"
echo " release: the name of release version to build"
echo " snapshot: the name of the next snapshot version"
exit 1
fi
#Make sure both branches are up to date
git checkout $DEVELOP_BRANCH
git fetch origin
git fetch origin $RELEASE_BRANCH:$RELEASE_BRANCH
developDiff=$(git log HEAD..origin/$DEVELOP_BRANCH --oneline)
if [[ "$developDiff" != "" ]]; then
echo "Branch '$DEVELOP_BRANCH' is not up to date."
exit 1
fi
releaseDiff=$(git log $RELEASE_BRANCH..origin/$RELEASE_BRANCH --oneline)
if [[ "$developDiff" != "" ]]; then
echo "Branch '$RELEASE_BRANCH' is not up to date."
exit 1
fi
#Create env variables for release version/snapshot
export RELEASE="$1"
export SNAPSHOT="$2"
#Create a release candidate branch
git checkout -b "$WORK_PREFIX/$RELEASE" $DEVELOP_BRANCH
#Update the poms for release version
mvn -DnewVersion=$RELEASE -f pom.xml versions:set
#Commit the pom version changes
git commit -am "Updating version for $RELEASE"
#Finish the release
git checkout $RELEASE_BRANCH
git merge --no-edit --no-ff "$WORK_PREFIX/$RELEASE"
SIGN_TAG=""
[ $(git config --get user.signingkey) != "" ] && SIGN_TAG="-s"
git tag $SIGN_TAG -m "Release $RELEASE" "$TAG_PREFIX-$RELEASE"
git checkout $DEVELOP_BRANCH
git merge --no-edit --no-ff $WORK_PREFIX/$RELEASE
git branch -d "$WORK_PREFIX/$RELEASE"
#Update the master branch with new snapshot version
mvn -DnewVersion=$SNAPSHOT -f pom.xml versions:set
#Commit the pom version changes
git commit -am "Updating version for $SNAPSHOT"
#Push master, release, and tags
git push origin master
git push origin release
git push --tags
echo "Release process complete!"