forked from linkedin/rest.li
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-version
executable file
·54 lines (47 loc) · 1.45 KB
/
release-version
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
#!/bin/sh
remote="origin"
branch="master"
if [ $# -eq 2 ]
then
remote=$1
branch=$2
fi
version=`awk 'BEGIN { FS = "=" }; $1 == "version" { print $2 }' gradle.properties`
echo "Attempting to publish: $version"
echo
DIRTY=`git status --porcelain --untracked-files=no 2>&1 || echo FAIL`
if [ -n "$DIRTY" ]
then
echo "Dirty index or working tree. Use git status to check."
echo "After resolution, run this command again."
exit 1
fi
LATEST_RELEASED_VERSION=$(git tag | tail -n 1)
DIFF=`git diff --quiet $remote/$branch $LATEST_RELEASED_VERSION >/dev/null 2>&1 ; echo $?`
if [ $DIFF -eq 0 ]
then
echo "No commit between latest released version $LATEST_RELEASED_VERSION and $remote/$branch."
exit 1
fi
INCONSISTENT=`git diff --quiet $remote/$branch >/dev/null 2>&1 ; echo $?`
if [ $INCONSISTENT -ne 0 ]
then
echo "$remote/$branch and current branch are inconsistent."
echo "Use git diff $remote/$branch to see changes."
echo "Rebase or push, as appropriate, and run this command again."
exit 1
fi
CHANGELOG=`grep $version CHANGELOG >/dev/null 2>&1 ; echo $?`
if [ $CHANGELOG -ne 0 ]
then
echo "No entry in the CHANGELOG for version $version."
echo "To get a list of changes, use git log previous_tag.."
echo "Add an entry to the CHANGELOG and run this command again."
exit 1
fi
if [ ! $SKIP_TAGGING_VERSION ]
then
git tag v$version && \
git push $remote v$version && \
echo "Publish completed successfully."
fi