-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_version.sh
81 lines (67 loc) · 1.82 KB
/
tag_version.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
#!/bin/bash
#
# Bumps the repo version number and commits, then tags.
#
# Usage:
#
# tag_version.sh <version_number>
#
# where:
#
# version_number: desired version number (symantic numbering preferred).
#
# Copyright 2019, University of Wisconsin Regents.
# Licensed under the GNU GPLv3.
rc=0
if [ $# != 1 ] ;
then
if [ $# == 1 ] && [ $1 == "-h" ] ;
then
sleep 0
else
echo $'\n'"ERROR: Incorrect number of arguments ($#), must be 1."$'\n'
rc=1
fi
echo "usage: tag_version.sh <version_number>"\
$'\n\n'"where:"\
$'\n\t'"version_number: desired version number (symantic numbering preferred)."
exit $rc
fi
VERSION_TAG=$1
# Absolute path to the directory this script is in
#scriptdir=$(realpath $(dirname $0))
scriptdir=$(readlink -f $(dirname $0))
echo "The proposed tag is: "$VERSION_TAG
echo "The current directory is "$scriptdir
CSPP_SOUNDER_QL_VERSION_FILE=$scriptdir/VERSION
# Edit the VERSION file in the repo root
if [ -f $CSPP_SOUNDER_QL_VERSION_FILE ] && [ -w $CSPP_SOUNDER_QL_VERSION_FILE ];
then
echo $CSPP_SOUNDER_QL_VERSION_FILE" exists!"
VERSION=$(cat $CSPP_SOUNDER_QL_VERSION_FILE)
echo "VERSION = "$VERSION
echo "Deleting old file "$CSPP_SOUNDER_QL_VERSION_FILE
rm -f $CSPP_SOUNDER_QL_VERSION_FILE
echo "Creating new VERSION file..."
echo $VERSION_TAG >> $CSPP_SOUNDER_QL_VERSION_FILE
else
echo $CSPP_SOUNDER_QL_VERSION_FILE" does not exist or is not writable!"
exit 1
fi
git commit -a -m "Bumped version to '$VERSION_TAG'"
if [ $? -eq 0 ] ;
then
echo "Commit command succeeded"
else
echo "Commit command failed, aborting."
exit 1
fi
git tag -a 'cspp-sounder-ql-'$VERSION_TAG -m "Release $VERSION_TAG"
if [ $? -eq 0 ] ;
then
echo "Tag command succeeded"
else
echo "Tag command failed, aborting."
exit 1
fi
exit 0