-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate-release-tag.sh
executable file
·92 lines (72 loc) · 2.53 KB
/
create-release-tag.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
#!/bin/bash
set -o errexit #abort if any command fails
function ensure_git_clean {
echo "==> Verifying repository is clean"
if [[ $(git status --porcelain) ]]; then
echo "ERROR: repository not in a clean state"
exit 1
fi
echo "==> Verifying local branch is not ahead of remote"
GITBRANCH=$(git rev-parse --abbrev-ref HEAD)
GITAHEAD="$(git log origin/$GITBRANCH..$GITBRANCH)"
if [ "$?" != "0" ]; then
echo "ERROR: failed to verify against upstream branch $GITBRANCH"
exit 1
fi
if [ "$GITBRANCH" != "master" ]; then
echo "ERROR: it appears you are on a non-master branch. This is not allowed"
exit 1
fi
if [ ! -z "$GITAHEAD" ]; then
echo "ERROR: it appears you have git changes that have not been pushed upstream. Building not allowed."
exit 1
fi
}
ensure_git_clean
OLDVERSION=$(cat VERSION)
if [ -z "$1" ]; then
NEWVERSION=$(./increment_version.sh -p $OLDVERSION)
else
NEWVERSION="$1"
fi
echo "Old version: $OLDVERSION"
echo "New version: $NEWVERSION"
EXPECTED_CHANGELOG="changelogs/$NEWVERSION.md"
if [ ! -f "$EXPECTED_CHANGELOG" ]; then
echo "ERROR: changelog not found (expected file $EXPECTED_CHANGELOG)"
echo ""
read -p "Press any key to view commits between $OLDVERSION and HEAD ... "
./changelog.sh $OLDVERSION
echo ""
echo "Please use this information to write a changelog, and place it in ./$EXPECTED_CHANGELOG"
echo "(use './changelog.sh $OLDVERSION' to see the commits since the previous version)"
exit 1
fi
#echo "=> Validating release hierarchy"
#if [ -z "$(git describe | grep $OLDVERSION)" ]; then
# echo "ERROR: Can not increment ('git describe' indicates state is not directly descendent from previous version or release candidate version)"
# exit 1
#else
# echo "Direct descendant from previous version"
#fi
if git rev-parse $NEWVERSION >/dev/null 2>&1; then
echo "ERROR: New version tag exists already"
exit 1
fi
ASSEMBLYVERSION="$NEWVERSION.0"
# appveyor build will take build version from assembly version and check it against tag
sed -i -E "s/\(Version(\"\)\([0-9]*\.\)\{1,\}\([0-9]*\)\")/Version(\"$ASSEMBLYVERSION\")/g" GlobalAssemblyInfo.cs
rm GlobalAssemblyInfo.cs-E
echo $NEWVERSION > VERSION
GIT_MESSAGE="Version bump from $OLDVERSION to $NEWVERSION"
git commit VERSION GlobalAssemblyInfo.cs -m "$GIT_MESSAGE"
git push
git tag -a "$NEWVERSION" -m "$GIT_MESSAGE"
git push --tags
echo "=> DONE"
echo ""
echo ""
echo "New git tag pushed: $NEWVERSION with message \"$GIT_MESSAGE\""
echo ""
# echo "=> Publishing the latest documentation"
# docs/manual/publish.sh